コード例 #1
0
    def callback(self):

        if self.b_procs:
            termios.tcsetattr(self.fd, termios.TCSADRAIN, self.old_settings)
            reset_screen()  # reset the screen to hide the log list
            reset_screen_dbg()
            tty.setraw(sys.stdin.fileno())

        if self.b_log:
            termios.tcsetattr(self.fd, termios.TCSADRAIN, self.old_settings)
            reset_screen()
            reset_screen_dbg()
            print('Log output active:\n')
            self.tail(self.max_log_lines)
            tty.setraw(sys.stdin.fileno())

        uptime = time.time() - self.startTime
        minutes = int(uptime // 60 % 60)
        hours = int(uptime // 3600 % 24)
        days = int(uptime // 86400)

        sys.stdout.write(
            'Running... ' + next(self.spinner) +
            '                                           ' +
            'Uptime: {:02d}:{:02d} - {:03d} days'.format(hours, minutes, days))

        sys.stdout.flush()
        sys.stdout.write('\r')
コード例 #2
0
ファイル: web_daemon.py プロジェクト: luisroberto0/Pythonic
    def start(self, args):

        logging.info('<#>DAEMON STARTED<#>')
        reset_screen()

        if self.args.Debug:
            reset_screen_dbg()
            self.stdinReader.start()  # call run() method in separate thread

        self.wsgi_server.start()
        self.operator.start()
コード例 #3
0
    def start(self, args):

        reset_screen()

        if self.args.Ex:
            reset_screen_dbg()
            self.stdinReader.start()  # call run() method in separate thread

        self.config = self.config_loader.loadConfigSync()

        self.wsgi_server.start()
        self.operator.start(self.config)
コード例 #4
0
    def printProcessList(self):

        # Unix Only
        termios.tcsetattr(self.fd, termios.TCSADRAIN, self.orig_tty_settings)
        reset_screen()
        reset_screen_dbg()
        
        for threadIdentifier, processHandle in self.proc_list:   
            if processHandle.pid:
                print('{} - process, pid: {}'.format(threadIdentifier, processHandle.pid))
            else:
                print('{} - thread'.format(threadIdentifier))

        print('\n')

        tty.setraw(sys.stdin.fileno()) 
コード例 #5
0
    def run(self):

        if self.b_init:
            self.b_init = False
            self.fd = sys.stdin.fileno()
            if os.isatty(sys.stdin.fileno()):
                self.old_settings = termios.tcgetattr(self.fd)
                tty.setraw(sys.stdin.fileno())

        while not self.b_exit:

            rd_fs, wrt_fs, err_fs = select.select([sys.stdin], [], [],
                                                  self.interval)

            if rd_fs and os.isatty(sys.stdin.fileno()):
                cmd = rd_fs[0].read(1)

                if cmd == ('q' or 'Q'):  # quit
                    termios.tcsetattr(self.fd, termios.TCSADRAIN,
                                      self.old_settings)
                    termios.tcflush(self.fd, termios.TCIOFLUSH)
                    self.b_exit = True
                    self.quit_app.emit()

                elif cmd == ('p' or 'P'):  # show proccesses
                    self.b_procs = True
                    termios.tcsetattr(self.fd, termios.TCSADRAIN,
                                      self.old_settings)
                    self.printProcessList()
                    tty.setraw(sys.stdin.fileno())

                elif cmd == ('l' or 'L'):  # show log
                    if self.b_log:
                        termios.tcsetattr(self.fd, termios.TCSADRAIN,
                                          self.old_settings)
                        reset_screen()  # reset the screen to hide the log list
                        reset_screen_dbg()
                        tty.setraw(sys.stdin.fileno())
                    self.b_log = not self.b_log

                else:
                    sys.stdout.write('\b')

            else:
                if os.isatty(sys.stdin.fileno()):
                    self.callback()