コード例 #1
0
    def __try_reconnect(self):
        output_lock.acquire()
        self.ml.blank_readline()

        output_msg(_('Connection lost! Trying to reconnect...'))
        retries = 0
        while True:
            retries += 1
            try:
                time.sleep(2)
                self.connect()
                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))))
コード例 #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()
コード例 #3
0
ファイル: repl.py プロジェクト: capc/middleware
    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()
コード例 #4
0
ファイル: repl.py プロジェクト: capc/middleware
    def __try_reconnect(self):
        output_lock.acquire()
        self.ml.blank_readline()

        output_msg(_('Connection lost! Trying to reconnect...'))
        retries = 0
        while True:
            retries += 1
            try:
                time.sleep(2)
                self.connect()
                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))))
コード例 #5
0
ファイル: commands.py プロジェクト: capc/middleware
 def run(self, context, args, kwargs, opargs):
     output_lock.acquire()
     os.system('cls' if os.name == 'nt' else 'clear')
     output_lock.release()
コード例 #6
0
 def run(self, context, args, kwargs, opargs):
     output_lock.acquire()
     os.system('cls' if os.name == 'nt' else 'clear')
     output_lock.release()