(20260123) Many day manual run possible now.
This commit is contained in:
+36
-16
@@ -175,26 +175,46 @@ if __name__ == "__main__":
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description = "Manual attendance sync. script.")
|
||||
parser.add_argument(
|
||||
"-date", "--d",
|
||||
help = "The date on which you want to sync attendance.",
|
||||
"--from-date",
|
||||
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()
|
||||
)
|
||||
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)
|
||||
tcaoff_creds = json.from_file(tcaoff_creds_file)
|
||||
manual_attendance(
|
||||
cosec_creds = cosec_creds,
|
||||
tcaoff_creds = tcaoff_creds,
|
||||
target_date = date_time.parse_date_time(
|
||||
args.d,
|
||||
date_formats = [
|
||||
"%Y%m%d",
|
||||
"%Y-%m-%d"
|
||||
],
|
||||
) + date_time.timedelta(
|
||||
hours = 23,
|
||||
minutes = 59
|
||||
|
||||
# Run the attendance for each specified date:
|
||||
for target_date in dates_list:
|
||||
print("TARGET DATE:", target_date)
|
||||
manual_attendance(
|
||||
cosec_creds = cosec_creds,
|
||||
tcaoff_creds = tcaoff_creds,
|
||||
target_date = date_time.parse_date_time(
|
||||
target_date,
|
||||
date_formats = [
|
||||
"%Y%m%d",
|
||||
"%Y-%m-%d"
|
||||
],
|
||||
) + date_time.timedelta(
|
||||
hours = 23,
|
||||
minutes = 59
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user