Exemplo n.º 1
0
class VersionCommand(basecommand.BaseCommand):
    u"""
    Displays the version of the package you are currently in.

    """

    command_name = u'version'
    description = u'Display Version of the package containing the current ' +\
        u'directory'
    usage = u'ftw %s' % command_name

    def __call__(self):
        scm.tested_for_scms(('svn', 'gitsvn'), '.')
        svn_url = scm.get_svn_url('.').split('/')
        svn_root_url = scm.get_package_root_url('.').split('/')
        package_name = scm.get_package_name('.')
        path = os.path.abspath(os.path.join(
                (len(svn_url) - len(svn_root_url) - 1) * '../',
                package_name.replace('.', '/'),
                'version.txt',
                ))
        if not os.path.isfile(path):
            output.error('Could not find file %s' % path, exit=1)
        version = open(path).read().strip()
        print '  Version of %s: %s' % (
            output.colorize(package_name, output.WARNING),
            output.colorize(version, output.WARNING),
            )

basecommand.registerCommand(VersionCommand)
Exemplo n.º 2
0
    command_name = u'zopeinstance'
    command_shortcut = u'zi'
    description = u'Run bin/instance placeless'
    usage = u'ftw %s action [options]' % command_name
    use_optparse = False

    def __call__(self):
        path = ['.']
        zopeFound = False
        while not zopeFound:
            dir = os.listdir('/'.join(path))
            if '/' == os.path.abspath('/'.join(path)):
                error('File system root reached: no zope instance found ..',
                      exit=True)
            elif 'bin' in dir:
                binContents = os.listdir('/'.join(path + ['bin']))
                instances = filter(lambda x: x.startswith('instance'),
                                   binContents)
                if len(instances) > 0:
                    zopeFound = True
                else:
                    path.append('..')
            else:
                path.append('..')
        p = os.path.abspath('/'.join(path + ['bin', instances[0]]))
        cmd = '%s %s' % (p, ' '.join(sys.argv[2:]))
        runcmd(cmd, log=True)

basecommand.registerCommand(ZopeInstanceCommand)