(20260123) Many day manual run possible now.

This commit is contained in:
2026-01-23 16:00:56 +05:30
parent 2557b349a6
commit e2049b683f
3 changed files with 40 additions and 19 deletions
+24 -4
View File
@@ -175,20 +175,40 @@ if __name__ == "__main__":
import argparse import argparse
parser = argparse.ArgumentParser(description = "Manual attendance sync. script.") parser = argparse.ArgumentParser(description = "Manual attendance sync. script.")
parser.add_argument( parser.add_argument(
"-date", "--d", "--from-date",
help = "The date on which you want to sync attendance.", help = "The date from which you want to sync attendance.",
default = date_time.get_current_ist_date_time()
)
parser.add_argument(
"--to-date",
help = "The date till when you want to sync attendance.",
default = date_time.get_current_ist_date_time() default = date_time.get_current_ist_date_time()
) )
args = parser.parse_args() args = parser.parse_args()
print("Target Date:", args.d) args.from_date = date_time.parse_date_time(args.from_date, timezone = date_time.TIMEZONE_IST)
args.to_date = date_time.parse_date_time(args.to_date, timezone = date_time.TIMEZONE_IST)
if args.from_date > args.to_date: args.from_date, args.to_date = args.to_date, args.from_date
print("From Date:", args.from_date)
print(" To Date:", args.to_date)
dates_list = [args.from_date]
while args.from_date < args.to_date:
args.from_date = args.from_date + datetime.timedelta(days = 1)
dates_list.append(args.from_date)
print(f"DATES ({len(dates_list)}):", dates_list)
# Load the credentials:
cosec_creds = json.from_file(cosec_creds_file) cosec_creds = json.from_file(cosec_creds_file)
tcaoff_creds = json.from_file(tcaoff_creds_file) tcaoff_creds = json.from_file(tcaoff_creds_file)
# Run the attendance for each specified date:
for target_date in dates_list:
print("TARGET DATE:", target_date)
manual_attendance( manual_attendance(
cosec_creds = cosec_creds, cosec_creds = cosec_creds,
tcaoff_creds = tcaoff_creds, tcaoff_creds = tcaoff_creds,
target_date = date_time.parse_date_time( target_date = date_time.parse_date_time(
args.d, target_date,
date_formats = [ date_formats = [
"%Y%m%d", "%Y%m%d",
"%Y-%m-%d" "%Y-%m-%d"
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -37,7 +37,6 @@ for team in team_list:
# Fix the app notes: # Fix the app notes:
cosec_notes = app_notes.get("cosec", {}) cosec_notes = app_notes.get("cosec", {})
print("COSEC NOTES:", cosec_notes)
cosec_notes = { cosec_notes = {
"User ID": cosec_notes.get("User ID", cosec_notes.get("UserID")), "User ID": cosec_notes.get("User ID", cosec_notes.get("UserID")),
"User Name": cosec_notes.get("User Name", cosec_notes.get("UserName")), "User Name": cosec_notes.get("User Name", cosec_notes.get("UserName")),
@@ -49,8 +48,10 @@ for team in team_list:
"Direct Reporting ID": cosec_notes.get("Direct Reporting ID", cosec_notes.get("DirectReportingID")), "Direct Reporting ID": cosec_notes.get("Direct Reporting ID", cosec_notes.get("DirectReportingID")),
"Level-1 ID": cosec_notes.get("Level-1 ID", cosec_notes.get("Level-1ID")), "Level-1 ID": cosec_notes.get("Level-1 ID", cosec_notes.get("Level-1ID")),
} }
print("COSEC NOTES:", cosec_notes)
# Save the JSON Notes again: # Save the JSON Notes again:
app_notes["cosec"] = cosec_notes
json_notes["applicantNotes"] = app_notes json_notes["applicantNotes"] = app_notes
team["json_notes"] = json.to_string(json_notes, no_space = True) team["json_notes"] = json.to_string(json_notes, no_space = True)
@@ -62,4 +63,4 @@ tcaoff.logout(tcaoff_creds)
# Show and save the DF: # Show and save the DF:
print(team_df[:10].to_string()) print(team_df[:10].to_string())
team_df[["user_id", "json_notes"]].to_csv(r"C:\Users\Khushal P Soonderji\Downloads\20260121_cosec_team_fix.csv", index = False) team_df[["user_id", "json_notes"]].to_csv(r"C:\Users\Khushal P Soonderji\Downloads\20260122_cosec_team_fix.csv", index = False)