Exemple #1
0
 def check_versions(self):
     output.part_title('Checking package versions')
     version_file = os.path.join(scm.get_package_name('.').replace('.', '/'),
                                 'version.txt')
     trunk_version = open(version_file).read().strip()
     print ' * Current version of trunk:         %s' %\
         output.colorize(trunk_version, output.WARNING)
     next_version = trunk_version.split('-')[0]
     existing_tags = scm.get_existing_tags('.')
     if next_version in existing_tags.keys():
         output.warning('Tag %s already existing' % next_version)
     # ask for next tag version
     prompt_msg = 'Which version do you want to release now? [%s]' % \
         output.colorize(next_version, output.BOLD_WARNING)
     next_version_input = input.prompt(prompt_msg, lambda v:v in existing_tags.keys() and 'Tag already existing' or True)
     if next_version_input:
         next_version = next_version_input
     # ask for next trunk version
     next_trunk_version = next_version + '-dev'
     next_trunk_version = self.bump_version_proposal(next_trunk_version)
     prompt_msg = 'Which version should trunk have afterwards? [%s]' % \
         output.colorize(next_trunk_version, output.BOLD_WARNING)
     next_trunk_version_input = input.prompt(prompt_msg)
     if next_trunk_version_input:
         next_trunk_version = next_trunk_version_input
     print ' * The version of the tag will be:   %s' %\
         output.colorize(next_version, output.WARNING)
     print ' * New version of the trunk will be: %s' %\
         output.colorize(next_trunk_version, output.WARNING)
     self.new_tag_version = next_version
     self.new_trunk_version = next_trunk_version
Exemple #2
0
    def get_svn_url(self, package_name):
        # what's the svn url?
        svn_url = None
        namespace = package_name.split('.')[0]
        # are there already packages checked out with same namespace?
        dirs = [os.path.abspath(d) for d in os.listdir('.')]
        dirs += [os.path.join(git.get_gitsvn_cache_path(), d)
                 for d in os.listdir(git.get_gitsvn_cache_path())]
        for path in dirs:
            dir = os.path.basename(path)
            if dir.startswith('%s.' % namespace):
                try:
                    tmp_url = '/'.join(
                        scm.get_package_root_url(
                            path).split('/')[:-1])
                    if tmp_url and \
                            '%s/' % package_name in svn.listdir(tmp_url):
                        svn_url = os.path.join(tmp_url, package_name, 'trunk')
                        break
                except scm.NotAScm:
                    pass
        if svn_url:
            print ' * found a package under %s' % svn_url
            msg = 'SVN project trunk url [%s]' % \
                output.colorize(svn_url, output.BOLD_WARNING)

            def input_validator(v):
                if not v:
                    return True
                if not svn.isdir(v.strip()):
                    return 'URL not found'
                return True

            url_input = input.prompt(msg, input_validator)
            if url_input:
                svn_url = url_input.strip()
        else:
            msg = 'SVN project trunk url:'

            def input_validator2(v):
                if not v or not svn.isdir(v.strip()):
                    return 'URL not found'
                return True

            url_input = input.prompt(msg, input_validator2)
            svn_url = url_input.strip()
        # check svn layout, give the user a chance to create the dirs
        svn.check_project_layout(svn_url, raise_exception=False)
        return svn_url
Exemple #3
0
 def notify(self, state, problem='', solution='', problem_level=0,
            pause=True):
     """Notify the user of a problem
     """
     if state:
         print '  OK'
     else:
         prob_type, prob_color = self.PROBLEM_LEVELS[problem_level]
         print ' ', output.colorize(prob_type, prob_color), \
             output.colorize(problem, prob_color)
         if solution:
             print '  SOLUTION:', solution
         if pause:
             input.prompt('[ENTER TO CONTINUE]')
     print ''
Exemple #4
0
 def check_pyprc(self):
     output.part_title('Checking .pypirc for egg-release targets')
     pypirc_path = os.path.expanduser('~/.pypirc')
     if not os.path.isfile(pypirc_path):
         # ~/.pypirc required
         output.error('Could not find the file %s' % pypirc_path, exit=True)
     config = ConfigParser.ConfigParser()
     config.readfp(open(pypirc_path))
     indexservers = config.get('distutils', 'index-servers').strip().split('\n')
     sections = []
     basic_namespace = scm.get_package_name('.').split('.')[0]
     for srv in indexservers:
         # test if its properly configured
         if config.has_section(srv):
             print '* found target "%s"' % output.colorize(srv,
                                                           output.WARNING)
             sections.append(srv)
     if basic_namespace in sections:
         self.pypi_target = basic_namespace
     else:
         self.pypi_target = ''
     msg = 'Please specify a pypi target for the egg relase [%s]' % \
         output.colorize(self.pypi_target, output.BOLD_WARNING)
     pypi_target_input = input.prompt(msg, lambda v:\
                                          (self.pypi_target and not v) or v in
                                      sections
                                      and True or 'Please select a target listed above')
     if pypi_target_input:
         self.pypi_target = pypi_target_input
Exemple #5
0
 def __call__(self):
     scm.tested_for_scms(('svn', 'gitsvn', 'git'), '.')
     self.check_doc()
     self.analyse()
     if self.options.release_egg:
         self.check_pyprc()
     if not self.options.release_egg_only:
         self.check_versions()
     print ''
     input.prompt('Are you sure to continue? [OK]')
     self.build_mo_files()
     self.pre_build_check()
     if not self.options.release_egg_only:
         self.bump_version_before_tagging()
         self.create_tag()
     if self.options.release_egg:
         self.release_egg()
     if not self.options.release_egg_only:
         self.bump_version_after_tagging()
Exemple #6
0
 def __call__(self):
     output.part_title('Configure ftw.manager')
     # get config path
     config = Configuration()
     config.initialize_configuration()
     # ask some questions
     syntax = input.prompt_bool('Enable color highlighting?', default=True)
     config.config.set('output', 'syntax', syntax)
     if syntax:
         # ask for scheme
         schemes = COLOR_SCHEMES.keys()
         current_scheme = config.color_scheme or 'light'
         def validator(value):
             return value.lower() in schemes+[''] and 1 or 'Select one of: %s' % ', '.join(schemes)
         print ' * Which color scheme would you like to use?'
         for s in schemes:
             print '   *', s
         scheme = input.prompt('Select color scheme [%s]:' %
                               '/'.join([s==current_scheme and s.upper() or s for s in schemes]), validator).lower()
         if not scheme:
             scheme = current_scheme
         config.config.set('output', 'scheme', scheme)
     # VCS
     opts = [config.default_vcs.upper()] + [o for o in ('svn', 'git')
                                            if o!=config.default_vcs]
     def input_validator(value):
         if not value or value.strip().lower() in ('svn', 'git'):
             return True
         else:
             return '"svn" or "git" ?'
     default_vcs = input.prompt('Whats your default VCS [%s]?' % '/'.join(opts),
                                input_validator).strip().lower()
     default_vcs = default_vcs or config.default_vcs
     if not config.config.has_section('general'):
         config.config.add_section('general')
     config.config.set('general', 'default_vcs', default_vcs)
     # and save
     config.write_config()
Exemple #7
0
    def guess_url(self, package, prompt=False, required=False):
        """ Tries to guess the url of a package. If it's not able to guess, it asks
        or returns None, dependening on *prompt*
        """
        # first, we check if we already know the name
        if self.has_package(package):
            return self.get(package)
        # we will search some places, make a list of possible hint-directories
        hint_dirs = []
        # the parent directory may contain the package or other packages with the same
        # namespace (e.g. src-directory)
        hint_dirs.append(os.path.abspath(".."))
        # the gitsvn-cache directory contains several packages, the required package or
        # a package with the same namespace?
        hint_dirs.append(os.path.abspath(git.get_gitsvn_cache_path()))

        # now we try to find the package in the hint_dirs
        for dir in hint_dirs:
            path = os.path.join(dir, package)
            if os.path.isdir(path) and is_scm(path):
                try:
                    url = get_package_root_url(path)
                except NotAScm:
                    pass
                else:
                    self.set(package, url)
                    return url

        # now lets guess it with the namespace...
        # first we check the packages we alreay know the path:
        namespace = package.split(".")[0]
        for pkg, url in self._packages.items():
            if pkg.startswith("%s." % namespace):
                try:
                    dir_url = "/".join(url.split("/")[:-1])
                    if package + "/" in svn.listdir(dir_url):
                        url = os.path.join(dir_url, package)
                        self.set(package, url)
                        return url
                except NotAScm:
                    pass

        # could not find any? we may need to ask the user...
        if prompt:

            def input_validator(v):
                if not required and not v:
                    return True
                if not v or not svn.isdir(v.strip()):
                    return "Invalid SVN-URL"
                return True

            colorized_package = output.colorize(package, output.BOLD_WARNING)
            msg = output.colorize("I'm having trouble to guess the SVN-URL for the package", output.WARNING)
            msg += " " + colorized_package
            print msg
            msg = "SVN-URL of %s" % colorized_package
            if not required:
                msg += output.colorize(" or nothing", output.WARNING)
            url_input = input.prompt(msg, input_validator)
            if url_input:
                url = svn.get_package_root_url(url_input)
                self.set(package, url)
                return url
        return None