Exemplo n.º 1
0
 def end_time(self):
     self.stop = True
     end_time_show = time.asctime()
     end_time = time.monotonic()
     execution_time = (timedelta(seconds=end_time - self.start_time))
     print(self.blue("End time ==> ") + self.white(end_time_show))
     print(
         self.blue("Execution time ==> ") +
         self.white(str(execution_time)) + "\n")
     term.saveCursor()
     term.pos(7, 15)
     term.writeLine("ok", term.green, term.blink)
     term.restoreCursor()
     exit(0)
Exemplo n.º 2
0
class Cursor:
    save = trm.saveCursor
    restore = trm.restoreCursor()
    up = lambda self, n: trm.up(n)
    pos = lambda self, r, c: trm.pos(r, c)
    down = lambda self, n: trm.down(n)
    home = lambda self: trm.homePos()
Exemplo n.º 3
0
 def exec(i):
     target = targets[i]
     ret = None
     try:
         log_path = os.path.join(config.logs_dir, str(target))
         log = open(log_path, 'w')
         proc = target.run(cmd, timeout=timeout, stdout=log, stderr=log)
         if proc.returncode == 0:
             output = f'{term.green}SUCCESS{term.off} on {target}'
         else:
             output = f'{term.red}FAIL{term.off} on {target}. Exit code: {proc.returncode}'
         ret = proc
     except RunException as e:
         output = f'{term.red}FAIL{term.off} on {target}. Timeout'
         ret = e
     output += f'. Log: file://{log_path}'
     with l:
         term.saveCursor()
         term.up(len(targets) - i)
         term.clearLine()
         term.writeLine(output)
         term.restoreCursor()
     return ret
Exemplo n.º 4
0
        trades = api.fetch_trades(symbol, limit=5)
        trades = pd.DataFrame(trades).drop(
            ['info', 'timestamp', 'symbol', 'fee', 'id', 'order', 'type'],
            axis=1)
        trades['amount'] = trades['amount'].apply(
            lambda v: '{: >16.3f}'.format(v))
        trades['cost'] = trades['cost'].apply(lambda v: '{: >16.8f}'.format(v))
        # print(trades.columns)
        trades['price'] = trades['price'].apply(
            lambda v: '{: >16.8f}'.format(v))

        trades['datetime'] = trades['datetime'].apply(
            lambda v: v.replace('T', ' ').replace('.000Z', ''))

        # print(trades.columns)
        trm.saveCursor(), [trm.clearLine()
                           for x in range(13)], trm.restoreCursor()
        trm.writeLine(trm.center('LAST TRADES'.format(symbol)))
        table_string = tabulate(trades, **market_trades_table_options)
        trm.writeLine('\n'.join(
            [trm.center(ln) for ln in table_string.split('\n')]))
        trm.writeLine(trm.center('\n - {} -'.format(get_time()[:-3])), trm.dim)

        tm.sleep(1.25)
    except (reqex.RequestException, reqex.ConnectionError) as err:
        trm.writeLine(str(err))
        tm.sleep(3)
    except KeyboardInterrupt:
        print('EXIT')
        break