From 8e51eebf26e899a4800cdad9b1f447b712b47312 Mon Sep 17 00:00:00 2001 From: zay <64491586+zaytiri@users.noreply.github.com> Date: Sun, 26 Mar 2023 11:41:57 +0100 Subject: [PATCH 1/2] fix date time utcnow() to just now() using utcnow() means it does not give the date of the device and if the date changes on the device, the scheduled jobs won't run; --- progscheduler/app.py | 2 +- progscheduler/jobs.py | 2 +- progscheduler/scheduler.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/progscheduler/app.py b/progscheduler/app.py index 82c8b75..e33c4d8 100644 --- a/progscheduler/app.py +++ b/progscheduler/app.py @@ -41,7 +41,7 @@ def is_time_to_stop_valid(program_name, time_to_stop): def is_scheduled_today(days_to_schedule): - now = datetime.utcnow() + now = datetime.now() return now.strftime("%A").lower() in days_to_schedule diff --git a/progscheduler/jobs.py b/progscheduler/jobs.py index d13de2b..8be41d4 100644 --- a/progscheduler/jobs.py +++ b/progscheduler/jobs.py @@ -5,7 +5,7 @@ def open_program(root_path): - now = datetime.utcnow() + now = datetime.now() os.startfile(root_path) show('The following file \n\t\t\t\'' + root_path + '\'\n\t\t has started at ' + str(now.hour).zfill(2) + ':' + str(now.minute).zfill(2) + ':' + str( now.second).zfill(2) + '.') diff --git a/progscheduler/scheduler.py b/progscheduler/scheduler.py index 33dce0e..6ad925a 100644 --- a/progscheduler/scheduler.py +++ b/progscheduler/scheduler.py @@ -101,5 +101,5 @@ def __schedule_method(self, time_to_schedule, day='everyday'): def __get_now_date(self): self.__seconds_delay += 1 - now = datetime.utcnow() + timedelta(seconds=self.__seconds_delay) + now = datetime.now() + timedelta(seconds=self.__seconds_delay) return str(now.hour).zfill(2) + ':' + str(now.minute).zfill(2) + ':' + str(now.second).zfill(2) From a5859b5430b91c9c46bb58417e9285bd20a04295 Mon Sep 17 00:00:00 2001 From: zay <64491586+zaytiri@users.noreply.github.com> Date: Sun, 26 Mar 2023 11:42:34 +0100 Subject: [PATCH 2/2] fix error checking for given path from the args --- progscheduler/settings/specific_arguments.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/progscheduler/settings/specific_arguments.py b/progscheduler/settings/specific_arguments.py index ee14520..2d76e86 100644 --- a/progscheduler/settings/specific_arguments.py +++ b/progscheduler/settings/specific_arguments.py @@ -92,7 +92,7 @@ def add_arguments(self, args_parser): default=argparse.SUPPRESS) def process_arguments(self, settings): - self.__check_any_errors() + self.__check_any_errors(settings[0].user_arguments) self.__process_days(settings[0].user_arguments) def __process_days(self, user_arguments): @@ -104,10 +104,10 @@ def __process_days(self, user_arguments): elif user_arguments.days[0] == 'everyday': user_arguments.days = self.__get_specific_days('everyday') - def __check_any_errors(self): + def __check_any_errors(self, user_args): try: - if not self.__given_argument_path_exists(self.path): - throw(self.path + '\' path does not exist.') + if not self.__given_argument_path_exists(user_args.path): + throw(user_args.path + '\' path does not exist.') except (AttributeError, TypeError): pass