(20260212) Moved to async version of cron reports.

This commit is contained in:
2026-02-12 11:00:19 +05:30
parent 94293cf2fc
commit beca5e3127
3 changed files with 356 additions and 17 deletions
+56 -5
View File
@@ -186,6 +186,57 @@ async def today_cron(
printer("TODAY CRON")
# Try the whole process once:
try:
# Log in to TCAOFF:
success = await tcaoff_client.login()
if not success: raise RuntimeError("TCAOFF Login Failed!")
# Try the part that needs COSEC:
try:
# Get the Muster Roll and then wait
# for the driver's resources to get freed:
success = common.get_muster_roll(
cosec_creds = cosec_creds,
on_date = date_time.get_current_ist_date_time().replace(
hour = 0,
minute = 0,
second = 0
),
cache_file = common.PREV_DAY_IN_OUT_SUMMARY_CACHE_FILE,
test_mode = test_mode
)
# Sync data between Cosec and TCAOFF:
if success:
print("MUSTER ROLL: Sync'ing with TCAOFF")
cosec_muster_roll = json.from_file(common.MUSTER_ROLL_CACHE_FILE)
await common.sync_branches_to_tcaoff(
tcaoff_client = tcaoff_client,
cosec_muster_roll = cosec_muster_roll,
)
await common.sync_departments_to_tcaoff(
tcaoff_client = tcaoff_client,
cosec_muster_roll = cosec_muster_roll,
)
await common.sync_teams_to_tcaoff(
tcaoff_client = tcaoff_client,
cosec_muster_roll = cosec_muster_roll,
)
# If something goes wrong in the COSEC step:
except Exception as exception:
err_printer(exception)
if test_mode: raise
# If something goes wrong:
except Exception as exception:
err_printer(exception)
await tcaoff_client.logout()
if test_mode: raise
# ---------------------------------------------------------------------------------------------------------------------
@@ -208,11 +259,11 @@ async def set_scheduler(
# If in test mode:
if test_mode:
printer("Starting Test")
await yesterday_cron(
cosec_creds = copy.deepcopy(cosec_creds),
tcaoff_client = tcaoff_client,
test_mode = test_mode
)
# await yesterday_cron(
# cosec_creds = copy.deepcopy(cosec_creds),
# tcaoff_client = tcaoff_client,
# test_mode = test_mode
# )
await today_cron(
cosec_creds = copy.deepcopy(cosec_creds),
tcaoff_client = tcaoff_client,