예제 #1
0
        def cb(result):
            i18n.installGettext()
            # handle some results specifically, like Result
            self.stdout.write("Invoking '%s' on '%s' returned:\n" %
                    (methodName, workerName))
            import pprint
            self.stdout.write("%s\n" % pprint.pformat(result))

            if isinstance(result, messages.Result):
                _headings = {
                    messages.ERROR: _('Error'),
                    messages.WARNING: _('Warning'),
                    messages.INFO: _('Note'),
                }

                for m in result.messages:
                    translator = i18n.Translator()
                    localedir = os.path.join(configure.localedatadir, 'locale')
                    # FIXME: add locales as messages from domains come in
                    translator.addLocaleDir(configure.PACKAGE, localedir)
                    self.stdout.write('%s:\n' % _headings[m.level])
                    self.stdout.write(translator.translate(m) + '\n')
                    if hasattr(m, 'timestamp'):
                        self.stdout.write(_("\nPosted on %s.\n") %
                            time.strftime("%c", time.localtime(m.timestamp)))
                    if m.debug:
                        self.stdout.write("DEBUG:\n%s\n" % m.debug)

                if result.failed:
                    self.stdout.write('Result failed.\n')
                else:
                    self.stdout.write('Result successful:\n%s\n' %
                        pprint.pformat(result.value))
예제 #2
0
        def cb(result):
            i18n.installGettext()
            # handle some results specifically, like Result
            self.stdout.write("Invoking '%s' on '%s' returned:\n" %
                              (methodName, workerName))
            import pprint
            self.stdout.write("%s\n" % pprint.pformat(result))

            if isinstance(result, messages.Result):
                _headings = {
                    messages.ERROR: _('Error'),
                    messages.WARNING: _('Warning'),
                    messages.INFO: _('Note'),
                }

                for m in result.messages:
                    translator = i18n.Translator()
                    localedir = os.path.join(configure.localedatadir, 'locale')
                    # FIXME: add locales as messages from domains come in
                    translator.addLocaleDir(configure.PACKAGE, localedir)
                    self.stdout.write('%s:\n' % _headings[m.level])
                    self.stdout.write(translator.translate(m) + '\n')
                    if hasattr(m, 'timestamp'):
                        self.stdout.write(
                            _("\nPosted on %s.\n") %
                            time.strftime("%c", time.localtime(m.timestamp)))
                    if m.debug:
                        self.stdout.write("DEBUG:\n%s\n" % m.debug)

                if result.failed:
                    self.stdout.write('Result failed.\n')
                else:
                    self.stdout.write('Result successful:\n%s\n' %
                                      pprint.pformat(result.value))
예제 #3
0
def main(args):
    global _retval

    parser = OptionParser(domain="flumotion-admin")
    parser.add_option('-m',
                      '--manager',
                      action="store",
                      type="string",
                      dest="manager",
                      help="the manager to connect to, e.g. localhost:7531")
    parser.add_option('',
                      '--no-ssl',
                      action="store_false",
                      dest="ssl",
                      default=True,
                      help="disable encryption when connecting to the manager")

    options, args = parser.parse_args(args)

    i18n.installGettext()

    if len(args) > 1:
        log.error('flumotion-admin', 'too many arguments: %r' % (args[1:], ))
        return 1

    from flumotion.ui.icons import register_icons
    register_icons()

    from flumotion.admin.gtk.dialogs import exceptionHandler
    sys.excepthook = exceptionHandler

    from flumotion.admin.gtk.adminwindow import AdminWindow
    win = AdminWindow()

    if options.verbose or (options.debug and options.debug > 3):
        win.setDebugEnabled(True)

    if options.manager:
        d = _connectToManager(win, options.manager, options.ssl)
    else:
        d = showGreeter(win)

    # Printout unhandled exception to stderr
    d.addErrback(twistedlog.err)

    # Fixes a bug on widnows version of twisted that makes
    # the application to crash because _simtag is not defined.
    if not hasattr(reactor, '_simtag'):
        reactor._simtag = None

    reactor.run()
    return _retval
예제 #4
0
def main(args):
    global _retval

    parser = OptionParser(domain="flumotion-admin")
    parser.add_option('-m', '--manager',
                      action="store", type="string", dest="manager",
                      help="the manager to connect to, e.g. localhost:7531")
    parser.add_option('', '--no-ssl',
                      action="store_false", dest="ssl", default=True,
                      help="disable encryption when connecting to the manager")

    options, args = parser.parse_args(args)

    i18n.installGettext()

    if len(args) > 1:
        log.error('flumotion-admin',
                  'too many arguments: %r' % (args[1:], ))
        return 1

    from flumotion.ui.icons import register_icons
    register_icons()

    from flumotion.admin.gtk.dialogs import exceptionHandler
    sys.excepthook = exceptionHandler

    from flumotion.admin.gtk.adminwindow import AdminWindow
    win = AdminWindow()

    if options.verbose or (options.debug and options.debug > 3):
        win.setDebugEnabled(True)

    if options.manager:
        d = _connectToManager(win, options.manager, options.ssl)
    else:
        d = showGreeter(win)

    # Printout unhandled exception to stderr
    d.addErrback(twistedlog.err)

    # Fixes a bug on widnows version of twisted that makes
    # the application to crash because _simtag is not defined.
    if not hasattr(reactor, '_simtag'):
        reactor._simtag = None

    reactor.run()
    return _retval
예제 #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