Exemplo n.º 1
0
def parse_options(args):
    usage = 'usage: flumotion-transcoder-admin [options] CONFIG-FILE'
    parser = optparse.OptionParser(usage=usage)
    parser.add_option('', '--version',
                      action="store_true", dest="version",
                      default=False,
                      help="show version information")
    parser.add_option('-D', '--daemonize',
                     action="store_true", dest="daemonize",
                     default=False,
                     help="run in background as a daemon")
    parser.add_option('', '--daemonize-to',
                     action="store", dest="daemonizeTo",
                     help="what directory to run from when daemonizing; "
                          "default: '/'")
    parser.add_option('-d', '--debug',
                     action="store", dest="debug",
                     help="override the configuration debug level")

    parser.add_option('-L', '--logdir',
                      action="store", dest="logdir",
                      help="flumotion log directory (default: %s)" %
                        configure.logdir)
    parser.add_option('-R', '--rundir',
                      action="store", dest="rundir",
                      help="flumotion run directory (default: %s)" %
                        configure.rundir)

    options, args = parser.parse_args(args)

    # Force options down configure's throat
    for d in ['logdir', 'rundir']:
        o = getattr(options, d, None)
        if o:
            log.debug('Setting configure.%s to %s' % (d, o))
            setattr(configure, d, o)

    if options.version:
        print common.version("flumotion-transcoder-admin")
        sys.exit(0)

    if options.daemonizeTo and not options.daemonize:
        raise iherrors.SystemError(
            '--daemonize-to can only be used with -D/--daemonize.')

    if len(args) != 2:
        sys.exit(usage)

    configPath = args[1]
    if not os.path.exists(configPath):
        raise iherrors.SystemError("Configuration file '%s' not found"
                                 % configPath)

    return options, configPath
Exemplo n.º 2
0
        def parse_args(self, args):
            options, args = OptionParser.parse_args(self, args)

            if options.verbose:
                log.setFluDebug("*:3")

            if options.version:
                print common.version(self.domain)
                import sys
                sys.exit(0)

            if options.debug:
                log.setFluDebug(options.debug)

            return options, args
Exemplo n.º 3
0
        def parse_args(self, args):
            options, args = OptionParser.parse_args(self, args)

            if options.verbose:
                log.setFluDebug("*:3")

            if options.version:
                print common.version(self.domain)
                import sys
                sys.exit(0)

            if options.debug:
                log.setFluDebug(options.debug)

            return options, args
Exemplo n.º 4
0
 def handleOptions(self, options):
     self.debug('command: handleOptions')
     if options.version:
         print version("flumotion-admin-command")
         return 0
Exemplo n.º 5
0
def main(args):
    from flumotion.common import setup
    setup.setupPackagePath()
    from flumotion.configure import configure
    log.debug('launch', 'Running Flumotion version %s' %
        configure.version)
    import twisted.copyright
    log.debug('launch', 'Running against Twisted version %s' %
        twisted.copyright.version)
    from flumotion.project import project
    for p in project.list():
        log.debug('launch', 'Registered project %s version %s' % (
            p, project.get(p, 'version')))

    parser = OptionParser(domain="flumotion-launch")

    log.debug('launch', 'Parsing arguments (%r)' % ', '.join(args))
    options, args = parser.parse_args(args)

    i18n.installGettext()

    # verbose overrides --debug
    if options.verbose:
        log.setFluDebug("*:3")

    # handle all options
    if options.version:
        print common.version("flumotion-launch")
        return 0

    if options.debug:
        log.setFluDebug(options.debug)

    # note parser versus parse
    configs = parse.parse_args(args[1:])

    # load the modules, make the component
    wrappers = [ComponentWrapper(config) for config in configs]

    # make socket pairs
    fds = make_pipes(wrappers)

    reactor.running = False
    reactor.failure = False
    reactor.callLater(0, lambda: setattr(reactor, 'running', True))

    d = start_components(wrappers, fds)

    def errback(failure):
        log.debug('launch', log.getFailureMessage(failure))
        print "Error occurred: %s" % failure.getErrorMessage()
        failure.printDetailedTraceback()
        reactor.failure = True
        if reactor.running:
            print "Stopping reactor."
            reactor.stop()
    d.addErrback(errback)

    if not reactor.failure:
        print 'Running the reactor. Press Ctrl-C to exit.'

        log.debug('launch', 'Starting reactor')
        reactor.run()

        log.debug('launch', 'Reactor stopped')

    if reactor.failure:
        return 1
    else:
        return 0
Exemplo n.º 6
0
 def testVersion(self):
     self.failUnless(common.version('abinary'))
Exemplo n.º 7
0
 def testVersion(self):
     self.failUnless(common.version('abinary'))
Exemplo n.º 8
0
 def handleOptions(self, options):
     self.debug('Nagios: handleOptions')
     if options.version:
         print common.version("flumotion-nagios")
         return 0
Exemplo n.º 9
0
 def handleOptions(self, options):
     self.debug('Nagios: handleOptions')
     if options.version:
         print common.version("flumotion-nagios")
         return 0