Beispiel #1
0
    def doCallback(self, args):
        try:
            methodName = args[0]
        except IndexError:
            common.errorRaise('Please specify a method name.')

        if len(args) > 1:
            args = common.parseTypedArgs(args[1], args[2:])
            if args is None:
                common.errorRaise('Could not parse arguments.')
        else:
            args = []

        d = self.getRootCommand().medium.callRemote(
            methodName, *args)

        def cb(result):
            import pprint
            self.stdout.write("Invoking '%s' on manager returned:\n%s\n" % (
                methodName, pprint.pformat(result)))

        def eb(failure):
            # FIXME
            if failure.check(errors.NoMethodError) \
                or failure.check(flavors.NoSuchMethod):
                common.errorRaise("No method '%s' on manager." % methodName)
            elif failure.check(errors.RemoteRunError):
                common.errorRaise(log.getFailureMessage(failure))
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #2
0
    def doCallback(self, args):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                "with 'component -i [component-id]'")

        p = self.parentCommand
        moodValue = p.componentState.get('mood')
        if moodValue == moods.sleeping.value:
            self.stdout.write("Component is already sleeping.\n")
            return 0

        d = self.getRootCommand().medium.callRemote('componentStop',
            self.parentCommand.componentState)

        def cb(result):
            self.stdout.write("Stopped component.\n")

        def eb(failure):
            if failure.trap(errors.ComponentMoodError):
                common.errorRaise("Component '%s' is in the wrong mood." %
                    self.parentCommand.componentId)
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #3
0
 def eb(failure):
     if failure.check(errors.ComponentMoodError,
                      errors.BusyComponentError):
         common.errorRaise("Component '%s' is in the wrong mood." %
             self.parentCommand.componentId)
     else:
         common.errorRaise(log.getFailureMessage(failure))
Beispiel #4
0
    def doCallback(self, args):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                              "with 'component -i [component-id]'")

        p = self.parentCommand
        moodValue = p.componentState.get('mood')
        if moodValue == moods.sleeping.value:
            self.stdout.write("Component is already sleeping.\n")
            return 0

        d = self.getRootCommand().medium.callRemote(
            'componentStop', self.parentCommand.componentState)

        def cb(result):
            self.stdout.write("Stopped component.\n")

        def eb(failure):
            if failure.trap(errors.ComponentMoodError):
                common.errorRaise("Component '%s' is in the wrong mood." %
                                  self.parentCommand.componentId)
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #5
0
 def eb(failure):
     if failure.check(errors.ComponentMoodError,
                      errors.BusyComponentError):
         common.errorRaise("Component '%s' is in the wrong mood." %
                           self.parentCommand.componentId)
     else:
         common.errorRaise(log.getFailureMessage(failure))
Beispiel #6
0
    def doCallback(self, args):
        try:
            methodName = args[0]
        except IndexError:
            common.errorRaise('Please specify a method name.')

        if len(args) > 1:
            args = common.parseTypedArgs(args[1], args[2:])
            if args is None:
                common.errorRaise('Could not parse arguments.')
        else:
            args = []

        d = self.getRootCommand().medium.callRemote(methodName, *args)

        def cb(result):
            import pprint
            self.stdout.write("Invoking '%s' on manager returned:\n%s\n" %
                              (methodName, pprint.pformat(result)))

        def eb(failure):
            # FIXME
            if failure.check(errors.NoMethodError) \
                or failure.check(flavors.NoSuchMethod):
                common.errorRaise("No method '%s' on manager." % methodName)
            elif failure.check(errors.RemoteRunError):
                common.errorRaise(log.getFailureMessage(failure))
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #7
0
    def handleOptions(self, options):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                "with 'component -i [component-id]'")

        # call our callback after connecting
        d = self.getRootCommand().loginDeferred
        d.addCallback(self._callback)
        d.addErrback(self._errback)
Beispiel #8
0
    def handleOptions(self, options):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                              "with 'component -i [component-id]'")

        # call our callback after connecting
        d = self.getRootCommand().loginDeferred
        d.addCallback(self._callback)
        d.addErrback(self._errback)
Beispiel #9
0
    def doCallback(self, args):
        u = self.parentCommand.uiState
        name = self._propertyName

        if not u.hasKey(name):
            common.errorRaise("Component '%s' does not have property '%s'." % (
                self.parentCommand.parentCommand.componentId, name))

        self.stdout.write("Property '%s' is '%r'.\n" % (
            name, u.get(name)))
Beispiel #10
0
    def doCallback(self, args):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                              "with 'component -i [component-id]'")

        p = self.parentCommand
        moodValue = p.componentState.get('mood')
        moodName = planet.moods.get(moodValue).name
        self.stdout.write("Component '%s' is %s.\n" %
                          (p.componentId, moodName))
Beispiel #11
0
    def doCallback(self, args):
        u = self.parentCommand.uiState
        name = self._propertyName

        if not u.hasKey(name):
            common.errorRaise(
                "Component '%s' does not have property '%s'." %
                (self.parentCommand.parentCommand.componentId, name))

        self.stdout.write("Property '%s' is '%r'.\n" % (name, u.get(name)))
Beispiel #12
0
    def doCallback(self, args):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                "with 'component -i [component-id]'")

        p = self.parentCommand
        moodValue = p.componentState.get('mood')
        moodName = planet.moods.get(moodValue).name
        self.stdout.write("Component '%s' is %s.\n" % (p.componentId,
            moodName))
Beispiel #13
0
    def doCallback(self, args):
        p = self.parentCommand
        s = p.workerHeavenState
        workers = s.get('workers')

        if not p.componentId:
            common.errorRaise("Please specify a component id "
                              "with 'component -i [component-id]'")

        self.stdout.write('Downstream Components:\n')

        d = defer.maybeDeferred(self.getUIState, p.componentState)
        d.addCallback(self.parentCommand.print_components, workers)
        return d
Beispiel #14
0
    def doCallback(self, args):
        p = self.parentCommand
        s = p.workerHeavenState
        workers = s.get('workers')

        if not p.componentId:
            common.errorRaise("Please specify a component id "
                "with 'component -i [component-id]'")

        self.stdout.write('Downstream Components:\n')

        d = defer.maybeDeferred(self.getUIState, p.componentState)
        d.addCallback(self.parentCommand.print_components, workers)
        return d
Beispiel #15
0
        def gotPlanetStateCb(result):
            self.planetState = result
            self.debug('gotPlanetStateCb')

            # only get componentState if we got passed an argument for it
            if not self.componentId:
                return

            try:
                self.componentState = util.findComponent(
                    result, self.componentId)
            except Exception, e:
                self.debug(log.getExceptionMessage(e))
                common.errorRaise("Invalid component id '%s'" %
                                  self.componentId)
Beispiel #16
0
        def gotPlanetStateCb(result):
            self.planetState = result
            self.debug('gotPlanetStateCb')

            # only get componentState if we got passed an argument for it
            if not self.componentId:
                return

            try:
                self.componentState = util.findComponent(result,
                    self.componentId)
            except Exception, e:
                self.debug(log.getExceptionMessage(e))
                common.errorRaise("Invalid component id '%s'" %
                    self.componentId)
Beispiel #17
0
 def eb(failure):
     if failure.check(errors.NoMethodError):
         common.errorRaise("No method '%s' on worker '%s'." % (methodName, workerName))
     elif failure.check(errors.SleepingComponentError):
         common.errorRaise("Component '%s' is sleeping." % p.componentId)
     elif failure.check(errors.RemoteRunError):
         common.errorRaise(log.getFailureMessage(failure))
     else:
         common.errorRaise(log.getFailureMessage(failure))
Beispiel #18
0
    def doCallback(self, args):
        try:
            filePath = args[0]
        except IndexError:
            common.errorRaise('Please specify a configuration file')

        if not os.path.exists(filePath):
            common.errorRaise("'%s' does not exist." % filePath)

        d = self.getRootCommand().medium.callRemote('loadConfiguration',
                                                    open(filePath).read())

        def eb(failure):
            common.errorRaise(log.getFailureMessage(failure))

        d.addErrback(eb)

        return d
Beispiel #19
0
    def doCallback(self, args):
        try:
            filePath = args[0]
        except IndexError:
            common.errorRaise('Please specify a configuration file')

        if not os.path.exists(filePath):
            common.errorRaise("'%s' does not exist." % filePath)

        d = self.getRootCommand().medium.callRemote('loadConfiguration',
            open(filePath).read())

        def eb(failure):
            common.errorRaise(log.getFailureMessage(failure))

        d.addErrback(eb)

        return d
Beispiel #20
0
 def eb(failure):
     if failure.check(errors.NoMethodError):
         common.errorRaise("No method '%s' on worker '%s'." %
                           (methodName, workerName))
     elif failure.check(errors.SleepingComponentError):
         common.errorRaise("Component '%s' is sleeping." %
                           p.componentId)
     elif failure.check(errors.RemoteRunError):
         common.errorRaise(log.getFailureMessage(failure))
     else:
         common.errorRaise(log.getFailureMessage(failure))
Beispiel #21
0
    def _callback(self, result):
        d = self.parentCommand.medium.callRemote('getPlanetState')

        def gotPlanetStateCb(result):
            self.planetState = result
            self.debug('gotPlanetStateCb')

            # only get componentState if we got passed an argument for it
            if not self.componentId:
                return

            try:
                self.componentState = util.findComponent(result,
                    self.componentId)
            except Exception, e:
                self.debug(log.getExceptionMessage(e))
                common.errorRaise("Invalid component id '%s'" %
                    self.componentId)
            self.debug('gotPlanetStateCb')
            if not self.componentState:
                common.errorRaise('Could not find component %s' %
                    self.componentId)
Beispiel #22
0
    def doCallback(self, args):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                "with 'component -i [component-id]'")

        d = self.getRootCommand().medium.callRemote('deleteComponent',
            self.parentCommand.componentState)

        def cb(result):
            self.stdout.write("Deleted component.\n")

        def eb(failure):
            if failure.trap(errors.ComponentMoodError):
                common.errorRaise("Component '%s' is in the wrong mood." %
                    self.parentCommand.componentId)
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
    def handleOptions(self, options):
        if not options.group:
            common.errorRaise("Please specify a group your encoding for "
                              "with '-g [group]'")
        self.group = options.group

        if not options.secret:
            common.errorRaise("Please specify the shared secret "
                              "with '-s [secret]'")
        self.secret = options.secret

        self.register_url = options.register_url
        self.interval = options.interval

        # call our callback after connecting
        if options.fake is not None:
            totals = eval(options.fake)
            while True:
                self.send_update(totals)
                time.sleep(self.interval)
        else:
            self.getRootCommand().loginDeferred.addCallback(self._callback)
Beispiel #24
0
    def _callback(self, result):
        d = self.parentCommand.medium.callRemote('getPlanetState')

        def gotPlanetStateCb(result):
            self.planetState = result
            self.debug('gotPlanetStateCb')

            # only get componentState if we got passed an argument for it
            if not self.componentId:
                return

            try:
                self.componentState = util.findComponent(
                    result, self.componentId)
            except Exception, e:
                self.debug(log.getExceptionMessage(e))
                common.errorRaise("Invalid component id '%s'" %
                                  self.componentId)
            self.debug('gotPlanetStateCb')
            if not self.componentState:
                common.errorRaise('Could not find component %s' %
                                  self.componentId)
Beispiel #25
0
    def handleOptions(self, options):
        if not options.group:
            common.errorRaise("Please specify a group your encoding for "
                "with '-g [group]'")
        self.group = options.group

        if not options.secret:
            common.errorRaise("Please specify the shared secret "
                "with '-s [secret]'")
        self.secret = options.secret

        self.register_url = options.register_url
        self.interval = options.interval

        # call our callback after connecting
        if options.fake is not None:
            totals = eval(options.fake)
            while True:
                self.send_update(totals)
                time.sleep(self.interval)
        else:
            self.getRootCommand().loginDeferred.addCallback(self._callback)
Beispiel #26
0
    def doCallback(self, args):
        p = self.parentCommand
        s = p.workerHeavenState
        workers = s.get('workers')

        if not p.componentId:
            common.errorRaise("Please specify a component id "
                "with 'component -i [component-id]'")

        eaters = p.componentState.get('config').get('eater', {})
        eaters_id = self.get_eaters_ids(eaters)
        comps = [p.componentState]
        while len(eaters_id) > 0:
            eaters = {}
            for i in eaters_id:
                try:
                    compState = util.findComponent(p.planetState, i)
                    comps.append(compState)
                    eaters.update(compState.get('config').get('eater', {}))
                except Exception, e:
                    self.debug(log.getExceptionMessage(e))
                    common.errorRaise("Error retrieving component '%s'" % i)
            eaters_id = self.get_eaters_ids(eaters)
Beispiel #27
0
    def doCallback(self, args):
        p = self.parentCommand
        s = p.workerHeavenState
        workers = s.get('workers')

        if not p.componentId:
            common.errorRaise("Please specify a component id "
                              "with 'component -i [component-id]'")

        eaters = p.componentState.get('config').get('eater', {})
        eaters_id = self.get_eaters_ids(eaters)
        comps = [p.componentState]
        while len(eaters_id) > 0:
            eaters = {}
            for i in eaters_id:
                try:
                    compState = util.findComponent(p.planetState, i)
                    comps.append(compState)
                    eaters.update(compState.get('config').get('eater', {}))
                except Exception, e:
                    self.debug(log.getExceptionMessage(e))
                    common.errorRaise("Error retrieving component '%s'" % i)
            eaters_id = self.get_eaters_ids(eaters)
Beispiel #28
0
    def doCallback(self, args):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                              "with 'component -i [component-id]'")

        d = self.getRootCommand().medium.callRemote(
            'deleteComponent', self.parentCommand.componentState)

        def cb(result):
            self.stdout.write("Deleted component.\n")

        def eb(failure):
            if failure.check(errors.ComponentMoodError,
                             errors.BusyComponentError):
                common.errorRaise("Component '%s' is in the wrong mood." %
                                  self.parentCommand.componentId)
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #29
0
 def eb(failure):
     # FIXME
     if failure.check(errors.NoMethodError) \
         or failure.check(flavors.NoSuchMethod):
         common.errorRaise("No method '%s' on manager." % methodName)
     elif failure.check(errors.RemoteRunError):
         common.errorRaise(log.getFailureMessage(failure))
     else:
         common.errorRaise(log.getFailureMessage(failure))
Beispiel #30
0
 def eb(failure):
     # FIXME
     if failure.check(errors.NoMethodError) \
         or failure.check(flavors.NoSuchMethod):
         common.errorRaise("No method '%s' on manager." % methodName)
     elif failure.check(errors.RemoteRunError):
         common.errorRaise(log.getFailureMessage(failure))
     else:
         common.errorRaise(log.getFailureMessage(failure))
Beispiel #31
0
    def doCallback(self, args):
        workerName = self.parentCommand.options.name
        if not workerName:
            common.errorRaise('Please specify a worker name with --name.')

        try:
            methodName = args[0]
        except IndexError:
            common.errorRaise('Please specify a method name.')

        if len(args) > 1:
            args = common.parseTypedArgs(args[1], args[2:])
            if args is None:
                common.errorRaise('Could not parse arguments.')
        else:
            args = []

        p = self.parentCommand
        d = self.getRootCommand().medium.callRemote('workerCallRemote',
                                                    workerName, methodName,
                                                    *args)

        def cb(result):
            import pprint
            self.stdout.write("Invoking '%s' on '%s' returned:\n%s\n" %
                              (methodName, workerName, pprint.pformat(result)))

        def eb(failure):
            # FIXME
            if failure.check(errors.NoMethodError):
                common.errorRaise("No method '%s' on worker '%s'." %
                                  (methodName, workerName))
            elif failure.check(errors.SleepingComponentError):
                common.errorRaise("Component '%s' is sleeping." %
                                  p.componentId)
            elif failure.check(errors.RemoteRunError):
                common.errorRaise(log.getFailureMessage(failure))
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #32
0
    def doCallback(self, args):
        workerName = self.parentCommand.options.name
        if not workerName:
            common.errorRaise('Please specify a worker name with --name.')

        try:
            methodName = args[0]
        except IndexError:
            common.errorRaise('Please specify a method name.')

        if len(args) > 1:
            args = common.parseTypedArgs(args[1], args[2:])
            if args is None:
                common.errorRaise('Could not parse arguments.')
        else:
            args = []

        p = self.parentCommand
        d = self.getRootCommand().medium.callRemote(
            'workerCallRemote', workerName, methodName, *args)

        def cb(result):
            import pprint
            self.stdout.write("Invoking '%s' on '%s' returned:\n%s\n" % (
                methodName, workerName, pprint.pformat(result)))

        def eb(failure):
            # FIXME
            if failure.check(errors.NoMethodError):
                common.errorRaise("No method '%s' on worker '%s'." % (
                    methodName, workerName))
            elif failure.check(errors.SleepingComponentError):
                common.errorRaise("Component '%s' is sleeping." %
                    p.componentId)
            elif failure.check(errors.RemoteRunError):
                common.errorRaise(log.getFailureMessage(failure))
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #33
0
    def doCallback(self, args):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                              "with 'component -i [component-id]'")

        try:
            methodName = args[0]
        except IndexError:
            common.errorRaise('Please specify a method name to invoke.')
        if len(args) > 1:
            args = common.parseTypedArgs(args[1], args[2:])
            if args is None:
                common.errorRaise('Could not parse arguments.')
        else:
            args = []

        p = self.parentCommand
        d = self.getRootCommand().medium.componentCallRemote(
            self.parentCommand.componentState, methodName, *args)

        def cb(result):
            if self.rawOutput:
                self.stdout.write(str(result))
            else:
                import pprint
                self.stdout.write(
                    "Invoking '%s' on '%s' returned:\n%s\n" %
                    (methodName, p.componentId, pprint.pformat(result)))

        def eb(failure):
            if failure.check(errors.NoMethodError):
                common.errorRaise("No method '%s' on component '%s'." %
                                  (methodName, p.componentId))
            elif failure.check(errors.SleepingComponentError):
                common.errorRaise("Component '%s' is sleeping." %
                                  p.componentId)
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #34
0
    def doCallback(self, args):
        if not self.parentCommand.componentId:
            common.errorRaise("Please specify a component id "
                "with 'component -i [component-id]'")

        try:
            methodName = args[0]
        except IndexError:
            common.errorRaise('Please specify a method name to invoke.')
        if len(args) > 1:
            args = common.parseTypedArgs(args[1], args[2:])
            if args is None:
                common.errorRaise('Could not parse arguments.')
        else:
            args = []

        p = self.parentCommand
        d = self.getRootCommand().medium.componentCallRemote(
            self.parentCommand.componentState, methodName, *args)

        def cb(result):
            if self.rawOutput:
                self.stdout.write(str(result))
            else:
                import pprint
                self.stdout.write("Invoking '%s' on '%s' returned:\n%s\n" % (
                        methodName, p.componentId, pprint.pformat(result)))

        def eb(failure):
            if failure.check(errors.NoMethodError):
                common.errorRaise("No method '%s' on component '%s'." % (
                    methodName, p.componentId))
            elif failure.check(errors.SleepingComponentError):
                common.errorRaise(
                    "Component '%s' is sleeping." % p.componentId)
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #35
0
    def doCallback(self, args):
        try:
            moduleName = args[0]
        except IndexError:
            common.errorRaise('Please specify a module name to invoke from.')
        try:
            methodName = args[1]
        except IndexError:
            common.errorRaise('Please specify a method name.')

        if len(args) > 2:
            args = common.parseTypedArgs(args[2], args[3:])
            if args is None:
                common.errorRaise('Could not parse arguments.')
        else:
            args = []

        p = self.parentCommand
        workerName = p.options.name
        d = self.getRootCommand().medium.callRemote('workerCallRemote',
                                                    workerName, 'runFunction',
                                                    moduleName, methodName,
                                                    *args)

        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))

        def eb(failure):
            if failure.check(errors.NoMethodError):
                common.errorRaise("No method '%s' on worker '%s'." %
                                  (methodName, workerName))
            elif failure.check(errors.SleepingComponentError):
                common.errorRaise("Component '%s' is sleeping." %
                                  p.componentId)
            elif failure.check(errors.RemoteRunError):
                common.errorRaise(log.getFailureMessage(failure))
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #36
0
    def doCallback(self, args):
        try:
            moduleName = args[0]
        except IndexError:
            common.errorRaise('Please specify a module name to invoke from.')
        try:
            methodName = args[1]
        except IndexError:
            common.errorRaise('Please specify a method name.')

        if len(args) > 2:
            args = common.parseTypedArgs(args[2], args[3:])
            if args is None:
                common.errorRaise('Could not parse arguments.')
        else:
            args = []

        p = self.parentCommand
        workerName = p.options.name
        d = self.getRootCommand().medium.callRemote(
            'workerCallRemote', workerName, 'runFunction',
            moduleName, methodName, *args)

        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))

        def eb(failure):
            if failure.check(errors.NoMethodError):
                common.errorRaise("No method '%s' on worker '%s'." % (
                    methodName, workerName))
            elif failure.check(errors.SleepingComponentError):
                common.errorRaise("Component '%s' is sleeping." %
                    p.componentId)
            elif failure.check(errors.RemoteRunError):
                common.errorRaise(log.getFailureMessage(failure))
            else:
                common.errorRaise(log.getFailureMessage(failure))

        d.addCallback(cb)
        d.addErrback(eb)

        return d
Beispiel #37
0
 def eb(failure):
     common.errorRaise(log.getFailureMessage(failure))
Beispiel #38
0
 def eb(failure):
     common.errorRaise(log.getFailureMessage(failure))
Beispiel #39
0
 def _errback(self, failure):
     failure.trap(errors.SleepingComponentError)
     common.errorRaise("Component '%s' is sleeping." %
                       self.parentCommand.componentId)
Beispiel #40
0
 def _errback(self, failure):
     failure.trap(errors.SleepingComponentError)
     common.errorRaise("Component '%s' is sleeping." %
         self.parentCommand.componentId)