Ejemplo n.º 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)
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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)
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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'))
Ejemplo n.º 14
0
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"))
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
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
Ejemplo n.º 17
0
def initialize_lpi(interactive = True):
    ''' Initialize launchpad binding, asking for credentials

        interactive is True by default if we want to ask the user to setup LP
        :return the launchpad object
    '''

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

    launchpad = None
    return_code = 0

    # check which server to address
    if lp_server == "staging":
        SERVICE_ROOT = STAGING_SERVICE_ROOT
        print _("WARNING: you are using staging and not launchpad real production server")
    else:
        SERVICE_ROOT = LPNET_SERVICE_ROOT

    # load stored LP credentials
    if interactive:
        print _("Get Launchpad Settings")
    launchpad = Launchpad.login_with(_('Quickly'),
                                     service_root=SERVICE_ROOT,
                                     allow_access_levels=["WRITE_PRIVATE"])

    # try to setup bzr
    me = launchpad.me
    (return_code, suggestion) = bzrbinding.bzr_set_login(me.display_name, me.preferred_email_address.email, me.name)

    if interactive:
        if launchpad is None or return_code != 0:
            if suggestion is None:
                 suggestion = _("Unknown reason")
            raise launchpad_connection_error(_("Couldn't setup Launchpad for quickly ; %s") % suggestion)
        print _("Launchpad connection is ok")

    return launchpad
Ejemplo n.º 18
0
def updatepackaging(changelog=None):
    """create or update a package using python-mkdebian.

    Commit after the first packaging creation"""

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

    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)
Ejemplo n.º 19
0
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
Ejemplo n.º 20
0
for_extras = False
i = 0

while i < len(sys.argv):
    arg = sys.argv[i]
    if arg.startswith('-'):
        if arg == '--extras':
            for_extras = True
        else:
            cmd = commands.get_command('package', 'ubuntu-application')
            templatetools.usage_error(_("Unknown option: %s."  % arg), cmd=cmd)
    i += 1

# retrieve useful information
if not configurationhandler.project_config:
    configurationhandler.loadConfig()
project_name = configurationhandler.project_config['project']

try:
    release_version = quicklyutils.get_setup_value('version')
except quicklyutils.cant_deal_with_setup_value:
    print _("Release version not found in setup.py.")


# creation/update debian packaging
if packaging.updatepackaging(no_changelog=True, installopt=for_extras) != 0:
    print _("ERROR: can't create or update ubuntu package")
    sys.exit(1)


# creating local binary package
Ejemplo n.º 21
0
choosed.""")


templatetools.handle_additional_parameters(sys.argv, help, usage=usage)

filelist = []
for root, dirs, files in os.walk('./'):
    for name in files:
        hide_path = root.endswith('_lib')
        py = name.endswith('.py')
        if py and not hide_path and name not in ('setup.py'):
            filelist.append(os.path.join(root, name))

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

# add launcher which does not end with .py for older projects (pre-lib split)
project_name = configurationhandler.project_config['project']
libdir = os.path.join(templatetools.python_name(project_name) + '_lib')
if not os.path.exists(libdir):
    filelist.append('bin/' + configurationhandler.project_config['project'])

# add helpfile sources
filelist.extend(glob.glob('help/C/*.page'))

editor = quicklyutils.get_quickly_editors()
if templatetools.in_verbose_mode():
    instance = subprocess.Popen([editor] + filelist)
else:
    nullfile = file("/dev/null")
Ejemplo n.º 22
0
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']
    version = get_python_mkdebian_version()
    if version >= 2.28:
        command.append('--force-control=full')
    else:
        command.append('--force-control')
    if 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_rules()

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

    # no, don't do this. autogenerated stuff should not be checked in and 
    # besides it potentially changes every time you run quickly package, 
    # which would create loads of spammy commits. also it is completely useless
    # to someone packaging for a different distro.

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

    #if re.match('(.|\n)*Untracked files:\n.*debian/(.|\n)*', git_status):
    #        return_code = filter_exec_command(["git", "commit", "-a", "-m", 'Creating ubuntu package'])

    return(return_code)
Ejemplo n.º 23
0
def set_bzrbranch(bzr_branch):
    '''set default bzr branch from where to pull and push'''

    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    configurationhandler.project_config['bzrbranch'] = bzr_branch
Ejemplo n.º 24
0
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"]
    version = get_python_mkdebian_version()
    if version >= 2.28:
        command.append("--force-control=full")
    else:
        command.append("--force-control")
    if 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_rules()

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

    # no, don't do this. autogenerated stuff should not be checked in and
    # besides it potentially changes every time you run quickly package,
    # which would create loads of spammy commits. also it is completely useless
    # to someone packaging for a different distro.

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

    # if re.match('(.|\n)*Untracked files:\n.*debian/(.|\n)*', git_status):
    #        return_code = filter_exec_command(["git", "commit", "-a", "-m", 'Creating ubuntu package'])

    return return_code
Ejemplo n.º 25
0
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']
    version = get_python_mkdebian_version()
    if version >= 2.28:
        command.append('--force-control=full')
    else:
        command.append('--force-control')
    if 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_rules()

    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)
Ejemplo n.º 26
0
def set_bzrbranch(bzr_branch):
    '''set default bzr branch from where to pull and push'''

    if not configurationhandler.project_config:
        configurationhandler.loadConfig()
    configurationhandler.project_config['bzrbranch'] = bzr_branch
Ejemplo n.º 27
0
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)