From 6159ec68ae0b4c071e5eff06ad488c405125e111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Omar=20S=C3=A1nchez=20Pizarro?= Date: Fri, 27 Oct 2023 15:16:50 +0200 Subject: [PATCH] fix time check of timenet api when need sleep after web request. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Omar Sánchez Pizarro --- app/timenet_manager.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/timenet_manager.py b/app/timenet_manager.py index 9c3e4fc..c4aaef6 100644 --- a/app/timenet_manager.py +++ b/app/timenet_manager.py @@ -58,7 +58,6 @@ class timenetManager: return self.get('check/info', {"guid": args.user}) def sendUpdate(self): - self.updateTime() if args.pin is None: # if pin is None, prompt for it @@ -87,22 +86,24 @@ class timenetManager: else: typ = args.type - data = { - "cp": config['user'], - "pin": args.pin, - "typ": typ, - "date": self.headers['tn-d'], - "geoLatitude": config['geo']['latitude'], - "geoLongitude": config['geo']['longitude'], - "geoError": "", - "c": 1, - "geoAccuracy": config['geo']['accuracy'] - } + response = None if not args.debug: self.addMessage("####HACIENDO CHECK####") - sleep(random.randint(80, 230)) + sleep(random.randint(0, 230)) + self.updateTime() + data = { + "cp": config['user'], + "pin": args.pin, + "typ": typ, + "date": self.headers['tn-d'], + "geoLatitude": config['geo']['latitude'], + "geoLongitude": config['geo']['longitude'], + "geoError": "", + "c": 1, + "geoAccuracy": config['geo']['accuracy'] + } response = self.post("check", data, self.headers) else: self.addMessage('Corriendo en modo debug. No se realizará ninguna acción')