From edc51ec153e456d3ff23220eacda7092ccf5a77c Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 19 Jun 2024 10:53:23 +0300 Subject: [PATCH] Jobber : Show errors. --- container/jobber/project/jobber/__init__.py | 61 ++++++++++----------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/container/jobber/project/jobber/__init__.py b/container/jobber/project/jobber/__init__.py index 3575d9fe..c55b7f3b 100644 --- a/container/jobber/project/jobber/__init__.py +++ b/container/jobber/project/jobber/__init__.py @@ -101,43 +101,38 @@ def toggle_button(cred, at_work): toggle_vpn(False) def main(): + # load users + users = open(USERS, 'r').readlines() + for user in users: + if user.startswith('#'): + users.remove(user) + print('loaded {} users'.format(len(users))) + + # loop forever while True: - try: - # load users - users = open(USERS, 'r').readlines() + print('time is {}h'.format(datetime.datetime.now().hour)) + + # check for day start + if datetime.datetime.now().hour == SHIFT_START and datetime.datetime.now().isoweekday() < 6: + print('starting work day..') for user in users: - if user.startswith('#'): - users.remove(user) - print('loaded {} users'.format(len(users))) + toggle_button(user, True) + time.sleep(random.random() * DELAY_CAP) - # loop forever - while True: - print('time is {}h'.format(datetime.datetime.now().hour)) + time.sleep(DELAY_SUCCESS) + continue - # check for day start - if datetime.datetime.now().hour == SHIFT_START and datetime.datetime.now().isoweekday() < 6: - print('starting work day..') - for user in users: - toggle_button(user, True) - time.sleep(random.random() * DELAY_CAP) + # check for day end + if datetime.datetime.now().hour == SHIFT_END and datetime.datetime.now().isoweekday() < 6: + print('ending work day..') + for user in users: + toggle_button(user, False) + time.sleep(random.random() * DELAY_CAP) - time.sleep(DELAY_SUCCESS) - continue + time.sleep(DELAY_SUCCESS) + continue - # check for day end - if datetime.datetime.now().hour == SHIFT_END and datetime.datetime.now().isoweekday() < 6: - print('ending work day..') - for user in users: - toggle_button(user, False) - time.sleep(random.random() * DELAY_CAP) - - time.sleep(DELAY_SUCCESS) - continue - - # loop delay - print('not the right time, waiting {}s'.format(DELAY_CYCLE)) - time.sleep(DELAY_CYCLE) - except: - time.sleep(DELAY_ERROR) - pass + # loop delay + print('not the right time, waiting {}s'.format(DELAY_CYCLE)) + time.sleep(DELAY_CYCLE)