From e4a8cb04d07c230305ee32230fe1b6d7e6c65b43 Mon Sep 17 00:00:00 2001 From: HappyZ Date: Thu, 13 Dec 2018 16:52:38 -0600 Subject: [PATCH] fix `request error 401` problem (finally) it turns out after reboot, we forget to re-authenticate in the script --- dpt-tools.py | 2 ++ python_api/libDPT.py | 2 ++ python_api/libInteractive.py | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/dpt-tools.py b/dpt-tools.py index 6a479d4..63067e6 100644 --- a/dpt-tools.py +++ b/dpt-tools.py @@ -107,6 +107,8 @@ def main(): "Make sure your id, key, and ip addresses are correct." ) exit(1) + dpt.client_id_fp = args.get('dpt_id', "") + dpt.key_fp = args.get('dpt_key', "") interactive(dpt, diagnosis=args.get('diagnosis', False)) diff --git a/python_api/libDPT.py b/python_api/libDPT.py index e8b7fb0..05db8ab 100644 --- a/python_api/libDPT.py +++ b/python_api/libDPT.py @@ -25,6 +25,8 @@ class DPT(): 8444/tcp open unknown 8445/tcp open unknown ''' + self.client_id_fp = "" + self.key_fp = "" self.debug = debug if addr is None: self.addr = "digitalpaper.local" diff --git a/python_api/libInteractive.py b/python_api/libInteractive.py index b8862aa..8ffb7de 100644 --- a/python_api/libInteractive.py +++ b/python_api/libInteractive.py @@ -125,6 +125,11 @@ def obtain_diagnosis_access(dpt): except BaseException as e: dpt.err_print(str(e)) return False + if not dpt.authenticate(dpt.client_id_fp, dpt.key_fp): + dpt.err_print("Cannot reauthenticate after reboot") + dpt.err_print("Client id filepath: {}".format(dpt.client_id_fp)) + dpt.err_print("Client key filepath: {}".format(dpt.key_fp)) + return False # step 2: reset root password if not reset_root_password(dpt): return False