Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
def update_apport(project_name, old_lp_project, new_lp_project):
    if not new_lp_project:
        return
    # crashdb file doesn't support spaces or dashes in the crash db name
    safe_project_name = project_name.replace(" ", "_").replace("-", "_")
    crashdb_file = "%s-crashdb.conf" % project_name
    hook_file = "source_%s.py" % project_name

    pathname = quickly.templatetools.get_template_path_from_project()
    template_pr_path = os.path.join(os.path.abspath(pathname), "store",
                                    "apport")
    relative_crashdb_dir = os.path.join("etc", "apport", "crashdb.conf.d")
    relative_apport_dir = "apport"

    existing_crashdb = os.path.join(relative_crashdb_dir, crashdb_file)
    existing_hook = os.path.join(relative_apport_dir, hook_file)

    template_crashdb_dir = os.path.join(template_pr_path, relative_crashdb_dir)
    template_hook_dir = os.path.join(template_pr_path, relative_apport_dir)

    # if the project name has changed, or any of the files are missing, then
    # attempt to set up the apport configuration and hooks
    if  not old_lp_project == new_lp_project \
        or not os.path.isfile(existing_crashdb) \
        or not os.path.isfile(existing_hook):

        subst_existing = ((old_lp_project, new_lp_project), )
        subst_new = (("safe_project_name", safe_project_name),
                     ("project_name", project_name), ("lp_project",
                                                      new_lp_project))

        if os.path.isfile(existing_crashdb):
            print _(
                "Updating project name references in existing apport crashdb configuration"
            )
            quicklyutils.update_file(existing_crashdb, subst_existing)
        elif os.path.isdir(template_crashdb_dir):
            print _("Creating new apport crashdb configuration")
            if not os.path.isdir(relative_crashdb_dir):
                os.makedirs(relative_crashdb_dir)
            templatetools.file_from_template(template_crashdb_dir,
                                             "project_name-crashdb.conf",
                                             relative_crashdb_dir, subst_new)

        if not os.path.isfile(existing_hook) and os.path.isdir(
                template_hook_dir):
            print _("Creating new apport hooks")
            if not os.path.isdir(relative_apport_dir):
                os.makedirs(relative_apport_dir)
            templatetools.file_from_template(template_hook_dir,
                                             "source_project_name.py",
                                             relative_apport_dir, subst_new)
Пример #4
0
def update_apport(project_name, old_lp_project, new_lp_project):
    if not new_lp_project:
        return
    # crashdb file doesn't support spaces or dashes in the crash db name
    safe_project_name = project_name.replace(" ", "_").replace("-","_")
    crashdb_file = "%s-crashdb.conf"%project_name
    hook_file = "source_%s.py"%project_name


    pathname = quickly.templatetools.get_template_path_from_project()
    template_pr_path = os.path.join(os.path.abspath(pathname), "store",
                                    "apport")
    relative_crashdb_dir = os.path.join("etc", "apport", "crashdb.conf.d")
    relative_apport_dir = "apport"
    
    existing_crashdb = os.path.join(relative_crashdb_dir, crashdb_file)
    existing_hook = os.path.join(relative_apport_dir, hook_file)
    
    template_crashdb_dir = os.path.join(template_pr_path, relative_crashdb_dir)
    template_hook_dir = os.path.join(template_pr_path, relative_apport_dir)

    # if the project name has changed, or any of the files are missing, then
    # attempt to set up the apport configuration and hooks
    if  not old_lp_project == new_lp_project \
        or not os.path.isfile(existing_crashdb) \
        or not os.path.isfile(existing_hook):

        subst_existing = ((old_lp_project, new_lp_project),)
        subst_new = (   ("safe_project_name", safe_project_name),
                        ("project_name", project_name),
                        ("lp_project", new_lp_project))

        if os.path.isfile(existing_crashdb):
            print _("Updating project name references in existing apport crashdb configuration")
            quicklyutils.update_file(existing_crashdb, subst_existing)
        elif os.path.isdir(template_crashdb_dir):
            print _("Creating new apport crashdb configuration")
            if not os.path.isdir(relative_crashdb_dir):
                os.makedirs(relative_crashdb_dir)
            templatetools.file_from_template(template_crashdb_dir, "project_name-crashdb.conf", relative_crashdb_dir, subst_new)

        if not os.path.isfile(existing_hook) and os.path.isdir(template_hook_dir):
            print _("Creating new apport hooks")
            if not os.path.isdir(relative_apport_dir):
                os.makedirs(relative_apport_dir)
            templatetools.file_from_template(template_hook_dir, "source_project_name.py", relative_apport_dir, subst_new)
Пример #5
0
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    project_name = configurationhandler.project_config['project']

    template_help_dir = os.path.join(abs_template_path, 'store', 'data',
                                     'mallard')

    # take files from command directory if don't exist
    help_page = os.path.join(template_help_dir, 't_o_p_i_c.page')

    if not os.path.isfile(help_page):
        template_help_dir = os.path.join(abs_command_path, 'store', 'data',
                                         'mallard')
        help_page = os.path.join(template_help_dir, 't_o_p_i_c.page')

    target_help_dir = os.path.join('help', 'C')
    if not os.path.exists(target_help_dir):
        os.makedirs(target_help_dir)

    python_name = templatetools.python_name(topic_name)
    sentence_name, cc_name = templatetools.conventional_names(topic_name)

    substitutions = (
        ('t_o_p_i_c', topic_name),
        ('sentence_name', sentence_name),
    )

    templatetools.file_from_template(template_help_dir, 't_o_p_i_c.page',
                                     target_help_dir, substitutions)
Пример #6
0
for root, dirs, files in os.walk(abs_path_project_root):
    try:
        relative_dir = root.split('project_root/')[1]
    except:
        relative_dir = ""
    # python dir should be replace by python_name (project "pythonified" name)
    if relative_dir.startswith('python'):
        relative_dir = relative_dir.replace('python', python_name)

    for directory in dirs:
        if directory == 'python':
            directory = python_name
        os.mkdir(os.path.join(relative_dir, directory))
    for filename in files:
        templatetools.file_from_template(root, filename, relative_dir, substitutions)

# set the mode to executable for executable file 
exec_file = os.path.join('bin', project_name)
try:
    os.chmod(exec_file, 0755)
except:
    pass

# Copy the specified SWF file into the project
shutil.copyfile(swf, os.path.join("data", "game.swf"))

# We require a specific version of the ubuntu-application template, so
# edit the project's .quickly file to specify it.
#WORKAROUND
fp = open(".quickly", "a")
Пример #7
0
    dialog_python_name = templatetools.python_name(dialog_name)
    dialog_sentence_name, dialog_camel_case_name = \
        templatetools.conventional_names(dialog_name)
    project_sentence_name, project_camel_case_name = \
        templatetools.conventional_names(project_name)
    dialog_name = dialog_name.replace('-','_')

    substitutions = (("project_name",project_name),
                     ("dialog_name",dialog_name),
                     ("dialog_python_name",dialog_python_name),
                     ("dialog_camel_case_name",dialog_camel_case_name),
                     ("project_camel_case_name",project_camel_case_name),
                     ("project_sentence_name",project_sentence_name),
                     ("dialog_sentence_name",dialog_sentence_name),
                     ("python_name",python_name))

    templatetools.file_from_template(template_ui_dir, 
                                    "dialog_camel_case_nameDialog.ui", 
                                    target_ui_dir, 
                                    substitutions)

    templatetools.file_from_template(template_ui_dir, 
                                    "dialog_python_name_dialog.xml", 
                                    target_ui_dir,
                                    substitutions)

    templatetools.file_from_template(template_python_dir, 
                                    "dialog_camel_case_nameDialog.py", 
                                    target_python_dir, 
                                    substitutions)
Пример #8
0
    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    project_name = configurationhandler.project_config['project']

    template_help_dir = os.path.join(abs_template_path, 'store', 'data',
                                     'mallard')

    # take files from command directory if don't exist
    help_page = os.path.join(template_help_dir, 'g_u_i_d_e.page')

    if not os.path.isfile(help_page):
        template_help_dir = os.path.join(abs_command_path, 'store', 'data',
                                         'mallard')
        help_page = os.path.join(template_help_dir, 'g_u_i_d_e.page')

    target_help_dir = os.path.join('help', 'C')
    if not os.path.exists(target_help_dir):
        os.makedirs(target_help_dir)

    python_name = templatetools.python_name(guide_name)
    sentence_name, cc_name = templatetools.conventional_names(guide_name)

    substitutions = (
        ('g_u_i_d_e', guide_name),
        ('sentence_name', sentence_name),
    )

    templatetools.file_from_template(template_help_dir, 'g_u_i_d_e.page',
                                     target_help_dir, substitutions)
Пример #9
0
    project_name = configurationhandler.project_config['project']

    template_help_dir = os.path.join(abs_template_path,
     'store', 'data', 'mallard')

    # take files from command directory if don't exist
    help_page = os.path.join(template_help_dir,
                               'g_u_i_d_e.page')

    if not os.path.isfile(help_page):
        template_help_dir = os.path.join(abs_command_path,
         'store', 'data', 'mallard')
        help_page = os.path.join(template_help_dir,
                   'g_u_i_d_e.page')

    target_help_dir = os.path.join('help', 'C')
    if not os.path.exists(target_help_dir):
        os.makedirs(target_help_dir)

    python_name = templatetools.python_name(guide_name)
    sentence_name, cc_name = templatetools.conventional_names(guide_name)
    
    substitutions = (
    ('g_u_i_d_e', guide_name),
    ('sentence_name', sentence_name),
    )

    templatetools.file_from_template(template_help_dir, 
                                    'g_u_i_d_e.page', 
                                    target_help_dir, substitutions)
Пример #10
0
            quicklyutils.set_setup_value('version', version.replace("~public", "-public"))
    except quicklyutils.cant_deal_with_setup_value:
        pass

    # add apport hooks if launchpad application is configured
    internal.apportutils.insert_lpi_if_required(project_name)
    lp_project_name = configurationhandler.project_config.get('lp_id', None)
    if lp_project_name is not None:
        internal.apportutils.update_apport(project_name, lp_project_name, lp_project_name)

    # new dialog file needs helpers.py
    if not os.path.isfile('%s/helpers.py' % python_name) and os.path.isdir(python_name):
        source_dir = os.path.join(os.path.dirname(__file__), 'project_root',
                                  'python')
        templatetools.file_from_template(source_dir, 
                                        "helpers.py", 
                                        python_name, 
                                        substitutions)

if project_version < '0.4.3':
    ## update dependencies format
    if 'dependencies' in configurationhandler.project_config \
        and not ',' in configurationhandler.project_config['dependencies']:
        dependencies = [elem for elem 
                        in configurationhandler.project_config['dependencies'].split(' ')
                        if elem]
        configurationhandler.project_config['dependencies'] = ", ".join(dependencies)
        configurationhandler.saveConfig()

if project_version < '0.4.4':
    # Use full modelines for all python files
    sedline = "sed -i 's/-\*- coding: utf-8 -\*-/-*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-/'"
Пример #11
0
    project_name = configurationhandler.project_config['project']

    template_help_dir = os.path.join(abs_template_path,
     'store', 'data', 'mallard')

    # take files from command directory if don't exist
    help_page = os.path.join(template_help_dir,
                               't_o_p_i_c.page')

    if not os.path.isfile(help_page):
        template_help_dir = os.path.join(abs_command_path,
         'store', 'data', 'mallard')
        help_page = os.path.join(template_help_dir,
                   't_o_p_i_c.page')

    target_help_dir = os.path.join('help', 'C')
    if not os.path.exists(target_help_dir):
        os.makedirs(target_help_dir)

    python_name = templatetools.python_name(topic_name)
    sentence_name, cc_name = templatetools.conventional_names(topic_name)

    substitutions = (
    ('t_o_p_i_c', topic_name),
    ('sentence_name', sentence_name),
    )

    templatetools.file_from_template(template_help_dir, 
                                    't_o_p_i_c.page', 
                                    target_help_dir, substitutions)
Пример #12
0
for root, dirs, files in os.walk(abs_path_project_root):
    try:
        relative_dir = root.split('project_root/')[1]
    except:
        relative_dir = ""
    # python dir should be replace by python_name (project "pythonified" name)
    if relative_dir.startswith('python'):
        relative_dir = relative_dir.replace('python', python_name)

    for directory in dirs:
        if directory.startswith('python'):
            directory = directory.replace('python', python_name)
        os.mkdir(os.path.join(relative_dir, directory))
    for filename in files:
        templatetools.file_from_template(root, filename, relative_dir, substitutions)

# set the mode to executable for executable file 
exec_file = os.path.join('bin', project_name)
try:
    os.chmod(exec_file, 0755)
except:
    pass

# add it to revision control
print _("Creating git repository and committing")
git_instance = subprocess.Popen(["git", "init"], stdout=subprocess.PIPE)
git_instance.wait()
git_instance = subprocess.Popen(["git", "add", "."], stdout=subprocess.PIPE)
git_instance.wait()
git_instance = subprocess.Popen(["git", "commit", "-m", "Initial project creation with Quickly!"], stderr=subprocess.PIPE)