Exemplo n.º 1
0
    def print_event(self, event, data):
        if self.event_divert:
            self.event_queue.put((event, data))
            return

        if event == 'task.progress':
            return

        output_lock.acquire()
        self.ml.blank_readline()

        translation = events.translate(self, event, data)
        if translation:
            output_msg(translation)
            if 'state' in data:
                if data['state'] == 'FAILED':
                    status = self.connection.call_sync('task.status',
                                                       data['id'])
                    output_msg("Task #{0} error: {1}".format(
                        data['id'], status['error']['message']))

        sys.stdout.flush()
        self.ml.restore_readline()
        output_lock.release()
Exemplo n.º 2
0
    def print_event(self, event, data):
        if self.event_divert:
            self.event_queue.put((event, data))
            return

        if event == 'task.progress':
            return

        output_lock.acquire()
        self.ml.blank_readline()

        translation = events.translate(self, event, data)
        if translation:
            output_msg(translation)
            if 'state' in data:
                if data['state'] == 'FAILED':
                    status = self.connection.call_sync('task.status',
                           data['id'])
                    output_msg("Task #{0} error: {1}".format(data['id'],
                           status['error']['message']))

        sys.stdout.flush()
        self.ml.restore_readline()
        output_lock.release()
Exemplo n.º 3
0
                        self.connection.login_user(getpass.getuser(), '')
                    else:
                        self.connection.login_token(self.connection.token)

                    self.connection.subscribe_events(*EVENT_MASKS)
                except RpcException:
                    output_msg(
                        _("Reauthentication failed (most likely token expired or server was restarted)"
                          ))
                    sys.exit(1)
                break
            except Exception, e:
                output_msg(_('Cannot reconnect: {0}'.format(str(e))))

        self.ml.restore_readline()
        output_lock.release()

    def attach_namespace(self, path, ns):
        splitpath = path.split('/')
        ptr = self.root_ns

        for n in splitpath[1:-1]:
            if n not in ptr.namespaces().keys():
                self.logger.warn(_("Cannot attach to namespace %s"), path)
                return

            ptr = ptr.namespaces()[n]

        ptr.register_namespace(ns)

    def connection_error(self, event):
Exemplo n.º 4
0
 def run(self, context, args, kwargs, opargs):
     output_lock.acquire()
     os.system('cls' if os.name == 'nt' else 'clear')
     output_lock.release()
Exemplo n.º 5
0
 def run(self, context, args, kwargs, opargs):
     output_lock.acquire()
     os.system('cls' if os.name == 'nt' else 'clear')
     output_lock.release()
Exemplo n.º 6
0
                try:
                    if self.hostname == '127.0.0.1':
                        self.connection.login_user(getpass.getuser(), '')
                    else:
                        self.connection.login_token(self.connection.token)

                    self.connection.subscribe_events(*EVENT_MASKS)
                except RpcException:
                    output_msg(_("Reauthentication failed (most likely token expired or server was restarted)"))
                    sys.exit(1)
                break
            except Exception, e:
                output_msg(_('Cannot reconnect: {0}'.format(str(e))))

        self.ml.restore_readline()
        output_lock.release()

    def attach_namespace(self, path, ns):
        splitpath = path.split('/')
        ptr = self.root_ns

        for n in splitpath[1:-1]:
            if n not in ptr.namespaces().keys():
                self.logger.warn(_("Cannot attach to namespace %s"), path)
                return

            ptr = ptr.namespaces()[n]

        ptr.register_namespace(ns)

    def connection_error(self, event):