From f4dd0cb9710eb0712a292eb240339d4aa766fd38 Mon Sep 17 00:00:00 2001 From: Kamina Date: Fri, 28 May 2021 07:23:36 -0400 Subject: [PATCH] add timer function --- nauta.py | 5 +++++ tools/__pycache__/timeset.cpython-39.pyc | Bin 0 -> 377 bytes tools/timeset.py | 6 ++++++ 3 files changed, 11 insertions(+) create mode 100644 tools/__pycache__/timeset.cpython-39.pyc create mode 100644 tools/timeset.py diff --git a/nauta.py b/nauta.py index 166e9d5..e2d8319 100755 --- a/nauta.py +++ b/nauta.py @@ -1,4 +1,6 @@ #!/usr/bin/env python3 +import sys +sys.path.append('tools/') from pprint import pprint from textwrap import dedent @@ -15,6 +17,7 @@ import re import logging +from timeset import * CONFIG_DIR = os.path.expanduser("~/.local/share/nauta/") try: @@ -196,6 +199,7 @@ def up(args): time.sleep(1) if not os.path.exists(LOGOUT_URL_FILE): break + timer(args, login_time, down) except KeyboardInterrupt: print("Got a Ctrl+C, logging out...") log("Got Ctrl+C. Attempting disconnect...") @@ -454,6 +458,7 @@ def main(args): up_parser = subparsers.add_parser('up') up_parser.set_defaults(func=up) up_parser.add_argument('username', nargs="?") + up_parser.add_argument('time', nargs="?") down_parser = subparsers.add_parser('down') down_parser.set_defaults(func=down) diff --git a/tools/__pycache__/timeset.cpython-39.pyc b/tools/__pycache__/timeset.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ba22eddb6be25b4e217dec4f74c04d298318fd98 GIT binary patch literal 377 zcmY*Vy-ve05Wce$2$d=^Ak;By7I*=KkdPP{x-gNYh1jVKPF&fJ5U5*t4I~)ZcoH5U zD-#nt6L%Fz<)r)W`|ihQ`)WKM0ol|0+x&~-2a8P;Bu>b~9)SXd7D`Y;$ww$r;RO`Q zCskltNe;ipJS9IR59b7tCL>1iEMB0;6;7ZR2rIY|{_KA~B4>NNO{qegdZa$FpedyN zv`wy7{= QM~zdR)yGIG@F5xg0FNC~vH$=8 literal 0 HcmV?d00001 diff --git a/tools/timeset.py b/tools/timeset.py new file mode 100644 index 0000000..76dfbff --- /dev/null +++ b/tools/timeset.py @@ -0,0 +1,6 @@ +import time +def timer(limit_time, init_time, logout_fun): + print('diff', int(time.time()) - init_time) + if limit_time.time and int(time.time()) - init_time >= int(limit_time.time): + print('You will be disconnected') + logout_fun([]) \ No newline at end of file