minor logic problems

This commit is contained in:
Bla 2023-10-26 14:35:30 +00:00
parent 1f6487237a
commit 5ec387e097

View file

@ -28,9 +28,11 @@ app = f("web")
h2 = timedelta(hours=2)
def interceptor(request, response): # A response interceptor takes two args
global lastUpdate
if 'ws-travis.dus.com/socket.io/?EIO=3&transport=polling' in request.url :
body = decode(response.body, response.headers.get('Content-Encoding', 'identity'))
x = re.split("\d\d\d:\d\d\/dus,", body.decode("utf-8"))
lastUpdate = datetime.now(timezone.utc)
for i in [i for i in x if i]:
try:
j = json.loads(i)
@ -121,7 +123,7 @@ if __name__ == '__main__':
# loop and restart with restartWait Interval
while True:
sleep(10)
sleep(30)
if datetime.now(timezone.utc) > lastaccess + restartWait:
d1 = createDriver()
d1.get('https://dus-travis.dus.com/')
@ -140,10 +142,14 @@ if __name__ == '__main__':
lastaccess = datetime.now(timezone.utc)
l = filter(idIsRecent,list(valuestore.keys()))
if len(list(l)) < 1:
restartWait = timedelta(seconds=60)
if len(list(l)) < 1 and lastUpdate < datetime.now(timezone.utc) - timedelta(seconds=90):
restartWait = timedelta(minutes=3)
print ("Something stupid happened, setting interval to 3m")
else:
restartWait = timedelta(hours=4)
if restartWait < timedelta(hours=1):
restartWait = timedelta(hours=4)
print ("Something stupid normalized, resetting interval to 4h")