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 0000000..ba22edd Binary files /dev/null and b/tools/__pycache__/timeset.cpython-39.pyc differ 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