Almost working, having some troubles with the blockers still
This commit is contained in:
parent
689a8cb1fc
commit
44c57aa881
@ -70,7 +70,7 @@ def update_crontab(pCurrent_Time, p_my_handler):
|
||||
global user_crontab
|
||||
global user_ids
|
||||
|
||||
p_my_handler.set_cron_interval(user_id = 1770205310, cron_interval = "50 11 * * *")
|
||||
p_my_handler.set_cron_interval(user_id = 1770205310, cron_interval = "8 17 * * *")
|
||||
|
||||
all_users = p_my_handler.get_all_users()
|
||||
|
||||
@ -83,16 +83,30 @@ def update_crontab(pCurrent_Time, p_my_handler):
|
||||
user_crontab.append(str(element["cron"]))
|
||||
|
||||
print(user_ids)
|
||||
update_based_on_crontab()
|
||||
update_based_on_crontab(user_ids, user_crontab)
|
||||
|
||||
p1 = Process(target= sleeping_time, args=(pCurrent_Time, ))
|
||||
p1.start()
|
||||
p3 = Process(target= update_based_on_crontab, args=(user_ids, user_crontab ) )
|
||||
p3.daemon = True
|
||||
p3.start()
|
||||
p1.join()
|
||||
p3.terminate()
|
||||
p1.terminate()
|
||||
|
||||
update_crontab(datetime.datetime.now(), p_my_handler)
|
||||
|
||||
|
||||
|
||||
def sleeping_time(pCurrent_Time):
|
||||
while True:
|
||||
time_difference = datetime.datetime.now() - pCurrent_Time
|
||||
if float(str(time_difference).split(':')[0]) >=1:
|
||||
print(time_difference)
|
||||
if float(str(time_difference).split(':')[1]) >=1: # every minute (0:00:03.646070) -> example time code
|
||||
update_crontab(datetime.datetime.now())
|
||||
break
|
||||
|
||||
|
||||
def update_based_on_crontab():
|
||||
def update_based_on_crontab(p_user_ids, p_user_crontab):
|
||||
|
||||
my_scheduler = BlockingScheduler()
|
||||
|
||||
@ -100,15 +114,13 @@ def update_based_on_crontab():
|
||||
|
||||
print(len(user_ids)) #Debug
|
||||
|
||||
for i in range(len(user_ids)):
|
||||
for i in range(len(p_user_ids)):
|
||||
print("in loop")
|
||||
cron_split = user_crontab[i].split(" ")
|
||||
cron_split = p_user_crontab[i].split(" ")
|
||||
print(cron_split[4], cron_split[1], cron_split[0], cron_split[3], cron_split[2])
|
||||
my_scheduler.add_job(update_for_user, 'cron', day_of_week = cron_split[4] , hour= cron_split[1] , minute = cron_split[0], month= cron_split[3] , day=cron_split[2], args=(user_ids[i], ))
|
||||
my_scheduler.add_job(update_for_user, 'cron', day_of_week = cron_split[4] , hour= cron_split[1] , minute = cron_split[0], month= cron_split[3] , day=cron_split[2], args=(p_user_ids[i], ))
|
||||
|
||||
my_scheduler.start()
|
||||
|
||||
print("update based on crontab")
|
||||
|
||||
def update_for_user(p_user_id):
|
||||
print("updating for {p_user_id}")
|
||||
@ -130,6 +142,7 @@ def send_to_user(pText, pUser_id = 1770205310):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print('This script shall not be run directly. Starting main_loop for debugging purposes.')
|
||||
try:
|
||||
main_loop()
|
||||
|
Loading…
Reference in New Issue
Block a user