Jobber : Show errors.

This commit is contained in:
Dmitry Voronin 2024-06-19 10:53:23 +03:00
parent d1c7bb2873
commit edc51ec153
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -101,43 +101,38 @@ def toggle_button(cred, at_work):
toggle_vpn(False) toggle_vpn(False)
def main(): 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: while True:
try: print('time is {}h'.format(datetime.datetime.now().hour))
# load users
users = open(USERS, 'r').readlines() # 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: for user in users:
if user.startswith('#'): toggle_button(user, True)
users.remove(user) time.sleep(random.random() * DELAY_CAP)
print('loaded {} users'.format(len(users)))
# loop forever time.sleep(DELAY_SUCCESS)
while True: continue
print('time is {}h'.format(datetime.datetime.now().hour))
# check for day start # check for day end
if datetime.datetime.now().hour == SHIFT_START and datetime.datetime.now().isoweekday() < 6: if datetime.datetime.now().hour == SHIFT_END and datetime.datetime.now().isoweekday() < 6:
print('starting work day..') print('ending work day..')
for user in users: for user in users:
toggle_button(user, True) toggle_button(user, False)
time.sleep(random.random() * DELAY_CAP) time.sleep(random.random() * DELAY_CAP)
time.sleep(DELAY_SUCCESS) time.sleep(DELAY_SUCCESS)
continue continue
# check for day end # loop delay
if datetime.datetime.now().hour == SHIFT_END and datetime.datetime.now().isoweekday() < 6: print('not the right time, waiting {}s'.format(DELAY_CYCLE))
print('ending work day..') time.sleep(DELAY_CYCLE)
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