Example #1
0
                    new_lines += missing_lines

                if len(files_to_remove) > 0:
                    output.warning('./MANIFEST.in: removed some unused lines:')
                    print output.colorize('\n'.join(files_to_remove), output.ERROR)
                    print ''
                    new_lines = filter(lambda x:x.strip() not in files_to_remove,
                                       new_lines)

                f = open('MANIFEST.in', 'w')
                f.write('\n'.join(new_lines))
                f.close()
                commit_message = 'updated MANIFEST.in for %s' % scm.get_package_name('.')
                modified = True

        if created or modified:
            # commit it ?
            if input.prompt_bool('Would you like to commit the MANIFEST.in?'):
                if created:
                    scm.add_and_commit_files(commit_message, 'MANIFEST.in')
                    return True
                elif modified:
                    scm.commit_files(commit_message, 'MANIFEST.in')
                    return True
            return False

        else:
            return True

basecommand.registerCommand(ReleaseCommand)
Example #2
0
        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 ''

    def notify_fix_completed(self):
        print output.colorize('Fix completed successfully', output.INFO)
        print ''

    def _validate_setup_py(self, respond=True, respond_error=True):
        """Runs the egg_info command on the ./setup.py for checking if it still
        works.

        """
        # usually run when something has changed. so lets
        # remove our cached egginfo stuff
        try:
            del self._egg_info
        except:
            pass
        cmd = '%s setup.py egg_info' % sys.executable
        return runcmd_with_exitcode(cmd, respond=respond,
                                    respond_error=respond_error)

registerCommand(EggCheckCommand)
Example #3
0
from ftw.manager.commands import basecommand
from ftw.manager.commands import zopeinstance
from ftw.manager.utils import scm
import sys


class TestCommand(basecommand.BaseCommand):
    u"""
    Runs the tests for the current package.
    This command only works if you are in a checkout directory of
    your package and the this directory is part of a buildout.

    """

    command_name = u'test'
    command_shortcut = u't'
    description = u'Run tests for current package'
    usage = u'ftw %s' % command_name

    def __call__(self):
        scm.tested_for_scms(('svn', 'gitsvn'), '.')
        package_name = scm.get_package_name('.')
        sys.argv = [sys.argv[0], 'zopeinstance', 'test', '-s', package_name]
        zopeinstance.ZopeInstanceCommand(self.maincommand)()

basecommand.registerCommand(TestCommand)
Example #4
0
            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()


basecommand.registerCommand(Setup)

Example #5
0
        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

basecommand.registerCommand(CheckoutCommand)
Example #6
0
            protocol += '://'
            credentials, rest = rest.split('@', 1)
            url = protocol + rest

            realm = HTTPRealmFinder(url).get()

            # install a basic auth handler
            if ':' in credentials:
                user, password = credentials.split(':', 1)
            else:
                user, password = credentials, None

            auth_handler = urllib2.HTTPBasicAuthHandler()
            auth_handler.add_password(realm=realm,
                                      uri=url,
                                      user=user,
                                      passwd=password)
            opener = urllib2.build_opener(auth_handler)
            urllib2.install_opener(opener)

        request = urllib2.Request(url)
        response = urllib2.urlopen(request)
        data = response.read()
        file_ = tempfile.NamedTemporaryFile()
        self._temporary_downloaded.append(file_)
        file_.write(data)
        file_.flush()
        return file_.name

basecommand.registerCommand(VersioninfoCommand)
Example #7
0
        return dependencies

    def download_file(self, url):
        """ Download file from *url*, store it in a tempfile and
        return its path

        """
        if not getattr(self, '_temporary_downloaded', None):
            # we need to keep a reference to the tempfile, otherwise it will
            # be deleted imidiately
            self._temporary_downloaded = []
        request = urllib2.Request(url)
        response = urllib2.urlopen(request)
        data = response.read()
        file_ = tempfile.NamedTemporaryFile()
        self._temporary_downloaded.append(file_)
        file_.write(data)
        file_.flush()
        return file_.name

    def delete_downloaded_files(self):
        for file_ in getattr(self, '_temporary_downloaded', []):
            try:
                file_.close()
            except:
                pass
            if os.path.exists(file_.name):
                os.remove(file_)

basecommand.registerCommand(DependencyCheckCommand)
Example #8
0
        if os.path.exists(manual_file):
            print '  merging manual pot file:', manual_file
            cmd.append('--merge %s' % manual_file)
        cmd.append('--create %s %s' % (
                domain,
                package_dir,
                ))
        cmd = ' \\\n'.join(cmd)
        runcmd(cmd)

    def register_options(self):
        self.parser.add_option('-d', '--domain', dest='domain',
                               action='store', default=None,
                               help='i18n domain. Default: package name')

basecommand.registerCommand(BuildPotCommand)


class SyncPoCommand(I18NDudeBaseCommand):
    u"""
    Syncs the .pot files with the .po files of the selected
    language. The files are synced with `i18ndude`, which may
    be installed using the extras_require.

    """
    command_name = u'i18nsync'
    command_shortcut = u'is'
    description = u'Syncs the .pot files with the .po files of a' +\
        'language.'
    usage = u'ftw %s [LANG-CODE]' % command_name
Example #9
0
            if '#instance' in '#'.join(dir):
                # we are in the bin folder
                path.append('..')
                return os.path.abspath('/'.join(path))
            if 'bin' in dir:
                bin_contents = os.listdir('/'.join(path+['bin']))
                if '#instance' in '#'.join(bin_contents):
                    # valid buildout directory reached
                    return os.path.abspath('/'.join(path))
            path.append('..')

    def unalias(self, nr):
        for aName, aNr in self.alias_map.items():
            if str(nr).lower()==str(aName).lower():
                return int(aNr)
        return int(nr)

    def alias(self, nr):
        for aName, aNr in self.alias_map.items():
            if str(nr).lower()==str(aNr).lower():
                return aName
        return nr

    def register_options(self):
        self.parser.add_option('-d', '--delay', dest='delay',
                               action='store', type='int', default=1,
                               help='Timeout between two instance calls')


basecommand.registerCommand(MultiinstanceCommand)
Example #10
0
    def __call__(self):
        # warning
        output.warning('It\'s no longer recommended to use a installation ' +\
                           'in site-packages, since we have a implicit ' +\
                           'dependency to zope.')
        output.warning('Use the buildout instead: ' +\
                           'https://svn.4teamwork.ch/repos/buildout/ftw.manager/')
        output.error('Quitting. See help for enforcing update...')
        if not self.options.ignore_warning:
            return
        # / warning
        from pkg_resources import load_entry_point
        easy_install = load_entry_point('setuptools==0.6c9', 'console_scripts',
                                        'easy_install')
        easy_install(['-U', '-f', self.options.findLinks, 'ftw.manager'])

    def register_options(self):
        default_psc_url = 'http://downloads.4teamwork.ch/4teamwork/ftw/simple'
        self.parser.add_option('-f', '--find-links', dest='findLinks',
                               action='store', type='string',
                               default=default_psc_url,
                               help='additional URL(s) to search for packages')
        self.parser.add_option('--ignore-warning', dest='ignore_warning',
                               action='store_true', default=False,
                               help='Ignore the warning not to use ' +\
                                   'site-package insetallation.')


basecommand.registerCommand(SelfUpdate)
Example #11
0
        """
        egg = distutils.core.run_setup('setup.py')
        return egg.get_long_description().split('\n')

    def show_description(self, rows=None, higlight=None):
        description = self.get_description()
        if not rows:
            rows = range(len(description))
        for i in rows:
            p = '%i:' % (i + 1) + ' ' + description[i]
            if i == higlight:
                print output.colorize(p, output.WARNING)
            else:
                print p

    def register_options(self):
        self.parser.add_option('-s', '--show-description', dest='show',
                               action='store_true', default=False,
                               help='show long-description of setup.py ' +\
                                   '(with line numbers)')
        self.parser.add_option('-b', '--show-inbrowser', dest='browser',
                               action='store_true', default=False,
                               help='Show description converted into HTML ' +\
                                   'in your default browser')
        self.parser.add_option('-o', '--off-rows', dest='offrows',
                               action='store', type='int', default=2,
                               help='show N rows before and after a bad ' +\
                                   'row (only if not using -s)')

basecommand.registerCommand(CheckdocsCommand)
Example #12
0
        show where this package is pinned in our KGSs.
        """
        for kgs_url in self.ftw_kgs_urls:
            kgs_packages = [k[1] for k in self.pinning_mapping
                            if k[0] == kgs_url][0]
            kgs_package_names = [p[0] for p in kgs_packages]
            if pkg_name in kgs_package_names:
                our_version = [p[2] for p in kgs_packages
                               if p[0] == pkg_name][0]
                yield (our_version, kgs_url)

    def _get_ftw_kgs_urls(self):
        """Extract all 4teamwork KGS URLs from a pinning mapping.
        """
        urls = []
        for kgs in self.pinning_mapping:
            url = kgs[0]
            for pattern in FTW_KGS_PATTERNS:
                if re.match(pattern, url):
                    urls.append(url)
        urls = list(set(urls))
        return sorted(urls)

    def register_options(self):
        self.parser.add_option('-c', '--config', dest='buildout',
                               action='store', default='./buildout.cfg',
                               help='Buildout config file containing version'
                                    'infos')

basecommand.registerCommand(CheckPinningsCommand)