Skip to content

Commit 0989cd7

Browse files
committed
cp_org_libs: switch to using ISO weekdays; fix 'should_run' calculation
1 parent eeaacd9 commit 0989cd7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

adabot/update_cp_org_libraries.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,17 @@ def update_json_file(working_directory, cp_org_dir, output_filename, json_string
166166
# check for the day we want this to run.
167167
if "TRAVIS" in os.environ:
168168
should_run = int(os.environ["CP_ORG_UPDATER_RUN_DAY"])
169-
if datetime.datetime.weekday(run_time) != should_run:
170-
should_run_date = datetime.date.today() - datetime.timedelta(days=(6 - should_run))
169+
if run_time.isoweekday() != should_run:
170+
delta_days = should_run - run_time.isoweekday()
171+
run_delta = datetime.timedelta(days=delta_days)
172+
should_run_date = run_time + run_delta
171173
msg = [
172174
"Aborting...",
173175
" - Today is not {}.".format(should_run_date.strftime("%A")),
176+
" - Next scheduled run is: {}".format(should_run_date.strftime("%Y-%m-%d")),
174177
" - To run the updater on a different day, change the",
175178
" 'CP_ORG_UPDATER_RUN_DAY' environment variable in Travis.",
176-
" - Day is a number between 0 & 6, with 0 being Monday."
179+
" - Day is a number between 1 & 7, with 1 being Monday."
177180
]
178181
print("\n".join(msg))
179182
sys.exit()

0 commit comments

Comments
 (0)