当前位置: 首页>>代码示例>>Python>>正文


Python configurationhandler.loadConfig函数代码示例

本文整理汇总了Python中quickly.configurationhandler.loadConfig函数的典型用法代码示例。如果您正苦于以下问题:Python loadConfig函数的具体用法?Python loadConfig怎么用?Python loadConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了loadConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_project

def create_project(argv):
    names, type_names = _get_names(argv)
    os.chdir(names.quickly_name)

    _create_project(names, type_names)
    try:
        os.mkdir("m4")
    except OSError:
        pass

    pandoramacros.copy_pandora_files()
        
    try:
        os.chmod("config/autorun.sh", 0755)
        os.chmod("config/pandora-plugin", 0755)
        os.chmod("config/config.rpath", 0755)
        os.chmod("test_run.sh", 0755)
    except:
        pass

    pandora_version = pandoramacros.get_pandora_version()

    licensing.licensing("GPL-3")

    configurationhandler.loadConfig()
    configurationhandler.project_config['project-type'] = type_names.project_name
    configurationhandler.project_config['pandora-version'] = pandora_version
    configurationhandler.saveConfig()
开发者ID:emonty,项目名称:pandora-build,代码行数:28,代码来源:createoradd.py

示例2: licensing

def licensing(license=None):
    """Add license or update it to the project files

    Default is GPL-3"""


    fauthors_name = "AUTHORS"
    flicense_name = "COPYING"

    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    project_name = configurationhandler.project_config['project']
    python_name = templatetools.python_name(project_name)

    # check if we have a license tag in setup.py otherwise, default to GPL-3
    if not license:
        try:
            license = quicklyutils.get_setup_value('license')
        except quicklyutils.cant_deal_with_setup_value:
            pass
    if not license:
        license = guess_license(flicense_name)
        if license == 'other':
            msg = _("COPYING contains an unknown license.  Please run 'quickly license other' to confirm that you want to use a custom license.")
            raise LicenceError(msg)
    if not license:
        license = 'GPL-3'

    supported_licenses_list = get_supported_licenses()
    supported_licenses_list.sort()
    if license not in supported_licenses_list and license != 'other':
        cmd = commands.get_command('license', 'ubuntu-application')
        templatetools.usage_error(_("Unknown licence %s.") % license, cmd=cmd)

    # get Copyright holders in AUTHORS file
    license_content = ""
    try:
        for line in file(fauthors_name, 'r'):
            if "<Your Name> <Your E-mail>" in line:
                # if we have an author in setup.py, grab it
                try:
                    author = quicklyutils.get_setup_value('author')
                    author_email = quicklyutils.get_setup_value('author_email')
                    line = "Copyright (C) %s %s <%s>\n" % (datetime.datetime.now().year, author, author_email)
                    # update AUTHORS file
                    fout = file('%s.new' % fauthors_name, 'w')
                    fout.write(line)
                    fout.flush()
                    fout.close()
                    os.rename(fout.name, fauthors_name)
                except quicklyutils.cant_deal_with_setup_value:
                    msg = _('Copyright is not attributed. ' \
                            'Edit the AUTHORS file to include your name for the copyright replacing ' \
                            '<Your Name> <Your E-mail>. Update it in setup.py or use quickly share/quickly release ' \
                            'to fill it automatically')
                    raise LicenceError(msg)
            license_content += "# %s" % line
    except (OSError, IOError), e:
        msg = _("%s file was not found") % fauthors_name
        raise LicenceError(msg)
开发者ID:dneelyep,项目名称:Programming-Directory,代码行数:60,代码来源:license.py

示例3: add

def add(options):
    if len(argv) != 2:
        templatetools.print_usage(options['indicator'])
        sys.exit(4)

    abs_template_path = templatetools.get_template_path_from_project()
    abs_command_path = os.path.abspath(os.path.dirname(sys.argv[0]))

    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    project_name = configurationhandler.project_config['project']

    template_python_dir = os.path.join(abs_template_path, 'store', 'python')
    # take files from command directory if don't exist
    python_file = os.path.join(template_python_dir,
                               'indicator.py')
    python_name = templatetools.python_name(project_name)
    target_python_dir = python_name

    project_sentence_name, project_camel_case_name = \
        templatetools.conventional_names(project_name)

    substitutions = (("project_name",project_name),
                    ( "python_name",python_name))

    templatetools.file_from_template(template_python_dir, 
                                    "indicator.py", 
                                    target_python_dir, 
                                    substitutions)
开发者ID:ali1234,项目名称:quickly-git-templates,代码行数:29,代码来源:indicator.py

示例4: copy_license_to_files

def copy_license_to_files(license_content):
    """Copy license header to every .py files"""

    # get the project name
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    project_name = configurationhandler.project_config['project']

    # open each python file and main bin file
    for root, dirs, files in os.walk('./'):
        for name in files:
            if name.endswith('.py') or os.path.join(root, name) == "./bin/" + project_name:
                target_file_name = os.path.join(root, name)
                try:
                    templatetools.update_file_content(
                        target_file_name,
                        BEGIN_LICENCE_TAG,
                        END_LICENCE_TAG,
                        '%s\n%s' % (BEGIN_LICENCE_TAG, license_content)
                        )
                except templatetools.CantUpdateFile, e:
                    print _("WARNING: %s was not found in the file %s. No licence replacement") % (END_LICENCE_TAG, target_file_name)
                except (OSError, IOError), e:
                    msg = _("%s file was not found") % target_file_name
                    raise LicenceError(msg)
开发者ID:GhostBSD,项目名称:apace,代码行数:25,代码来源:license.py

示例5: get_about_file_name

def get_about_file_name():
    """Get about file name if exists"""
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    about_file_name = "data/ui/About%sDialog.ui" % templatetools.get_camel_case_name(configurationhandler.project_config['project'])
    if not os.path.isfile(about_file_name):
        return None
    return about_file_name
开发者ID:emonty,项目名称:pandora-build,代码行数:8,代码来源:quicklyutils.py

示例6: updatepackaging

def updatepackaging(changelog=None, no_changelog=False, installopt=False):
    """create or update a package using python-mkdebian.

    Commit after the first packaging creation"""

    if not changelog:
        changelog = []
    command = ['python-mkdebian', '--force-control']
    if get_python_mkdebian_version() > 2.22:
        command.append("--force-copyright")
        command.append("--force-rules")
    if no_changelog:
        command.append("--no-changelog")
    if installopt:
       command.append("--prefix=/opt/extras.ubuntu.com/%s" % configurationhandler.project_config['project'])
    for message in changelog:
        command.extend(["--changelog", message])
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    dependencies = get_forced_dependencies()
    try:
        dependencies.extend([elem.strip() for elem
                             in configurationhandler.project_config['dependencies'].split(',')
                             if elem])
    except KeyError:
        pass
    for dep in dependencies:
        command.extend(["--dependency", dep])
    try:
        distribution = configurationhandler.project_config['target_distribution']
        command.extend(["--distribution", distribution])
    except KeyError:
        pass # Distribution has not been set by user, let python-mkdebian decide what it should be


    return_code = _exec_and_log_errors(command, True)
    if return_code != 0:
        print _("An error has occurred when creating debian packaging")
        return(return_code)

    if installopt:
        update_metadata()

    print _("Ubuntu packaging created in debian/")

    # check if first python-mkdebian (debian/ creation) to commit it
    # that means debian/ under unknown
    bzr_instance = subprocess.Popen(["bzr", "status"], stdout=subprocess.PIPE)
    bzr_status, err = bzr_instance.communicate()
    if bzr_instance.returncode != 0:
        return(bzr_instance.returncode)

    if re.match('(.|\n)*unknown:\n.*debian/(.|\n)*', bzr_status):
        return_code = filter_exec_command(["bzr", "add"])
        if return_code == 0:
            return_code = filter_exec_command(["bzr", "commit", "-m", 'Creating ubuntu package'])

    return(return_code)
开发者ID:dneelyep,项目名称:Programming-Directory,代码行数:58,代码来源:packaging.py

示例7: link_project

def link_project(launchpad, question, lp_project_name=None):
    ''' Link to launchpad project, erasing previous one if already set
    
    
        :return project object'''

    # if config not already loaded
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()

    if not lp_project_name:
        choice = "0"
        while choice == "0":

            lp_id = raw_input("%s, leave blank to abort.\nLaunchpad project name: " % question)
            if lp_id == "":
                raise launchpad_project_error(_("No launchpad project given, aborting."))
                
            prospective_projects = launchpad.projects.search(text=lp_id)
            project_number = 1
            project_names = []
            for project in prospective_projects:
                print (_('''---------------- [%s] ----------------
   %s
--------------------------------------
Project name: %s
Launchpad url: %s/%s
%s
''') % (project_number, project.title, project.display_name, launchpad_url, project.name, project.summary))
                project_names.append(project.name)
                project_number += 1            

            if not list(prospective_projects):
                message = _("No project found")
            else:
                message = _("Choose your project number")
            choice = raw_input("%s, leave blank to abort, 0 for another search.\nYour choice: " % message)

        try:
            choice = int(choice)
            if choice in range(1, project_number):
                project = launchpad.projects[project_names[choice - 1]]
            else:
                raise ValueError
        except ValueError:
            raise launchpad_project_error(_("No right number given, aborting."))

    # we got a project name, check that it exists
    else:
        try:
            project = launchpad.projects[lp_project_name]
        except KeyError:
            raise launchpad_project_error(_("Can't find %s project on Launchpad. You can try to find it interactively without providing a project name.") % lp_project_name)       

    configurationhandler.project_config['lp_id'] = project.name
    configurationhandler.saveConfig()
    
    return project
开发者ID:GhostBSD,项目名称:apace,代码行数:58,代码来源:launchpadaccess.py

示例8: updatepackaging

def updatepackaging(changelog=None, no_changelog=False):
    """create or update a package using python-mkdebian.

    Commit after the first packaging creation"""

    if not changelog:
        changelog = []
    command = ['python-mkdebian', '--force-control']
    if no_changelog:
        command.append("--no-changelog")
    for message in changelog:
        command.extend(["--changelog", message])
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    try:
        dependencies = [elem.strip() for elem
                        in configurationhandler.project_config['dependencies'].split(',')
                        if elem]
    except KeyError:
        dependencies = []

    # Hardcode the Flash plugin as a dependency, because it won't 
    # get noticed by the autodetector.
    dependencies += ["flashplugin-installer"]
    for dep in dependencies:
        command.extend(["--dependency", dep])

    try:
        distribution = configurationhandler.project_config['target_distribution']
        command.extend(["--distribution", distribution])
    except KeyError:
        pass # Distribution has not been set by user, let python-mkdebian decide what it should be


    return_code = _exec_and_log_errors(command, True)
    if return_code != 0:
        print _("An error has occurred when creating debian packaging")
        return(return_code)

    print _("Ubuntu packaging created in debian/")

    # check if first python-mkdebian (debian/ creation) to commit it
    # that means debian/ under unknown
    bzr_instance = subprocess.Popen(["bzr", "status"], stdout=subprocess.PIPE)
    bzr_status, err = bzr_instance.communicate()
    if bzr_instance.returncode != 0:
        return(bzr_instance.returncode)

    if re.match('(.|\n)*unknown:\n.*debian/(.|\n)*', bzr_status):
        return_code = filter_exec_command(["bzr", "add"])
        if return_code == 0:
            return_code = filter_exec_command(["bzr", "commit", "-m", 'Creating ubuntu package'])

    return(return_code)
开发者ID:dneelyep,项目名称:Programming-Directory,代码行数:54,代码来源:packaging.py

示例9: get_bzrbranch

def get_bzrbranch():
    '''get default bzr branch from where to pull and push'''
 
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()

    try:
        bzr_branch = configurationhandler.project_config['bzrbranch']
    except KeyError:
        bzr_branch = None
    return bzr_branch
开发者ID:ali1234,项目名称:quickly-git-templates,代码行数:11,代码来源:bzrutils.py

示例10: licensing

def licensing(license=None):
    """Add license or update it to the project files

    Default is GPL-3"""


    fauthors_name = "AUTHORS"
    flicense_name = "COPYING"

    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    project_name = configurationhandler.project_config['project']
    python_name = templatetools.python_name(project_name)

    # check if we have a license tag in plugin.ini otherwise, default to GPL-3
    if license is None:
        license = get_plugin_ini_value('license')
    if license is None or license == '':
        license = 'GPL'
    if license == 'PLUGIN_LICENSE_GPL':
        license = 'GPL-2'
    if license == 'PLUGIN_LICENSE_BSD':
        license = 'BSD'

    # get Copyright holders in AUTHORS file
    license_content = ""
    try:
        for line in file(fauthors_name, 'r'):
            if "<Your Name> <Your E-mail>" in line:
                # if we have an author in setup.py, grab it
                try:
                    author = get_plugin_ini_value('author')
                    if author is None:
                        raise quicklyutils.cant_deal_with_setup_value()
                    line = "Copyright (C) %s %s\n" % (datetime.datetime.now().year, author, author_email)
                    # update AUTHORS file
                    fout = file('%s.new' % fauthors_name, 'w')
                    fout.write(line)
                    fout.flush()
                    fout.close()
                    os.rename(fout.name, fauthors_name)
                except quicklyutils.cant_deal_with_setup_value:
                    msg = _('Copyright is not attributed. ' \
                            'Edit the AUTHORS file to include your name for the copyright replacing ' \
                            '<Your Name> <Your E-mail>. Update it in setup.py or use quickly share/quickly release ' \
                            'to fill it automatically')
                    raise LicenceError(msg)
            license_content += "%s" % line
    except (OSError, IOError), e:
        msg = _("%s file was not found") % fauthors_name
        raise LicenceError(msg)
开发者ID:emonty,项目名称:pandora-build,代码行数:51,代码来源:licensing.py

示例11: copy_license_to_files

def copy_license_to_files(license_content):
    """Copy license header to every .py, .cc or .h files"""

    # get the project name
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    project_name = configurationhandler.project_config['project']

    # open each python file and main bin file
    for root, dirs, files in os.walk('./'):
        for name in files:
            if name.endswith('.py') or \
              name.endswith('.h') or name.endswith('.hh') or \
              name.endswith('.c') or name.endswith('.cc') or \
              name.endswith('.am') or name.endswith('ac'):
                skip_until_end_found = False
                try:
                    target_file_name = os.path.join(root, name)
                    ftarget_file_name = file(target_file_name, 'r')
                    ftarget_file_name_out = file(ftarget_file_name.name + '.new', 'w')
                    for line in ftarget_file_name:
                        # seek if we have to add or Replace a License
                        if BEGIN_LICENCE_TAG_PY in line:
                            ftarget_file_name_out.write(line) # write this line, otherwise will be skipped
                            skip_until_end_found = True
                            ftarget_file_name_out.write(prefix_license(license_content, "#"))
                        if BEGIN_LICENCE_TAG_C in line:
                            ftarget_file_name_out.write(line) # write this line, otherwise will be skipped
                            skip_until_end_found = True
                            ftarget_file_name_out.write(prefix_license(license_content, " *"))

                        if END_LICENCE_TAG_C in line or END_LICENCE_TAG_PY in line:
                            skip_until_end_found = False

                        if not skip_until_end_found:
                            ftarget_file_name_out.write(line)


                    ftarget_file_name.close()
                    ftarget_file_name_out.close()

                    if skip_until_end_found: # that means we didn't find the END_LICENCE_TAG, don't copy the file
                        print _("WARNING: %s was not found in the file %s. No licence replacement") % (END_LICENCE_TAG, ftarget_file_name.name)
                        os.remove(ftarget_file_name_out.name)
                    else:
                        templatetools.apply_file_rights(ftarget_file_name.name, ftarget_file_name_out.name)
                        os.rename(ftarget_file_name_out.name, ftarget_file_name.name)

                except (OSError, IOError), e:
                    msg = _("%s file was not found") % fcopyright_name
                    raise LicenceError(msg)
开发者ID:emonty,项目名称:pandora-build,代码行数:51,代码来源:licensing.py

示例12: copy_license_to_files

def copy_license_to_files(license_content):
    """Copy license header to every .py files"""

    # get the project name
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    project_name = configurationhandler.project_config["project"]

    # open each python file and main bin file
    for root, dirs, files in os.walk("./"):
        for name in files:
            if name.endswith(".py") or os.path.join(root, name) == "./bin/" + project_name:
                skip_until_end_found = False
                try:
                    target_file_name = os.path.join(root, name)
                    ftarget_file_name = file(target_file_name, "r")
                    ftarget_file_name_out = file(ftarget_file_name.name + ".new", "w")
                    for line in ftarget_file_name:
                        # seek if we have to add or Replace a License
                        if BEGIN_LICENCE_TAG in line:
                            ftarget_file_name_out.write(line)  # write this line, otherwise will be skipped
                            skip_until_end_found = True
                            ftarget_file_name_out.write(license_content)

                        if END_LICENCE_TAG in line:
                            skip_until_end_found = False

                        if not skip_until_end_found:
                            ftarget_file_name_out.write(line)

                    ftarget_file_name.close()
                    ftarget_file_name_out.close()

                    if skip_until_end_found:  # that means we didn't find the END_LICENCE_TAG, don't copy the file
                        print _("WARNING: %s was not found in the file %s. No licence replacement") % (
                            END_LICENCE_TAG,
                            ftarget_file_name.name,
                        )
                        os.remove(ftarget_file_name_out.name)
                    else:
                        templatetools.apply_file_rights(ftarget_file_name.name, ftarget_file_name_out.name)
                        os.rename(ftarget_file_name_out.name, ftarget_file_name.name)

                except (OSError, IOError), e:
                    msg = _("%s file was not found") % target_file_name
                    raise LicenceError(msg)
开发者ID:ali1234,项目名称:quickly-git-templates,代码行数:46,代码来源:license.py

示例13: choose_ppa

def choose_ppa(launchpad, ppa_name=None):
    '''Look for right ppa parameters where to push the package'''

    if not ppa_name:
        if not configurationhandler.project_config:
            configurationhandler.loadConfig()
        try:
            (ppa_user, ppa_name) = get_ppa_parameters(launchpad, configurationhandler.project_config['ppa'])
        except KeyError:
            ppa_user = launchpad.me
            if (launchpadaccess.lp_server == "staging"):
                ppa_name = 'staging'
            else: # default ppa
                ppa_name = 'ppa'
    else:
        (ppa_user, ppa_name) = get_ppa_parameters(launchpad, ppa_name)
    ppa_url = '%s/~%s/+archive/%s' % (launchpadaccess.LAUNCHPAD_URL, ppa_user.name, ppa_name)
    dput_ppa_name = 'ppa:%s/%s' % (ppa_user.name, ppa_name)
    return (ppa_user, ppa_name, dput_ppa_name, ppa_url.encode('UTF-8'))
开发者ID:GhostBSD,项目名称:apace,代码行数:19,代码来源:packaging.py

示例14: choose_ppa

def choose_ppa(launchpad, ppa_name=None):
    """Look for right ppa parameters where to push the package"""

    if not ppa_name:
        if not configurationhandler.project_config:
            configurationhandler.loadConfig()
        try:
            (ppa_user, ppa_name) = get_ppa_parameters(launchpad, configurationhandler.project_config["ppa"])
        except KeyError:
            ppa_user = launchpad.me
            if launchpadaccess.lp_server == "staging":
                ppa_name = "staging"
            else:  # default ppa
                ppa_name = "ppa"
    else:
        (ppa_user, ppa_name) = get_ppa_parameters(launchpad, ppa_name)
    ppa_url = "%s/~%s/+archive/%s" % (launchpadaccess.LAUNCHPAD_URL, ppa_user.name, ppa_name)
    dput_ppa_name = "ppa:%s/%s" % (ppa_user.name, ppa_name)
    return (ppa_user, ppa_name, dput_ppa_name, ppa_url.encode("UTF-8"))
开发者ID:GhostBSD,项目名称:apace,代码行数:19,代码来源:packaging.py

示例15: get_project

def get_project(launchpad):
    ''' Get quickly project through launchpad.
    
        :return project object
    '''
 
    # if config not already loaded
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
       
    # try to get project
    try:
        lp_id = configurationhandler.project_config['lp_id']
        project = launchpad.projects[lp_id]
       
    # else, bind the project to LP
    except KeyError:
        project = link_project(launchpad, "No Launchpad project set")
        
    return project
开发者ID:GhostBSD,项目名称:apace,代码行数:20,代码来源:launchpadaccess.py


注:本文中的quickly.configurationhandler.loadConfig函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。