diff options
Diffstat (limited to 'Run/Que/client.py')
-rwxr-xr-x | Run/Que/client.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/Run/Que/client.py b/Run/Que/client.py index cd24618..4cf5d05 100755 --- a/Run/Que/client.py +++ b/Run/Que/client.py @@ -16,19 +16,22 @@ import urllib.request as request MAX_TIMEOUT = 99999999 # basically never timeout -def auth(): - conf_file = os.path.expanduser("~/.config/que.conf") - if not os.path.exists(conf_file): - sys.exit("you need a ~/.config/que.conf") - cfg = configparser.ConfigParser() - cfg.read(conf_file) - return cfg +def auth(args): + ns = args.target.split("/")[0] + if ns == "pub": + return None + else: + conf_file = os.path.expanduser("~/.config/que.conf") + if not os.path.exists(conf_file): + sys.exit("you need a ~/.config/que.conf") + cfg = configparser.ConfigParser() + cfg.read(conf_file) + return cfg[ns]["key"] def send(args): "Send a message to the que." - ns = args.target.split("/")[0] - key = auth()[ns]["key"] + key = auth(args) data = args.infile.read().encode("utf-8").strip() req = request.Request(f"{args.host}/{args.target}") req.add_header("User-AgenT", "Que/Client") @@ -44,8 +47,7 @@ def send(args): def recv(args): "Receive a message from the que." - ns = args.target.split("/")[0] - key = auth()[ns]["key"] + key = auth(args) def _recv(_req): msg = _req.readline().decode("utf-8").strip() |