Commit 0b0a0536 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

[backupserver promise] The cron date is actually in the system's timezone

parent 90cad43d
...@@ -48,6 +48,7 @@ setup(name=name, ...@@ -48,6 +48,7 @@ setup(name=name,
'GitPython', #needed for git manipulation into slaprunner 'GitPython', #needed for git manipulation into slaprunner
'croniter', # needed to know cron schedule 'croniter', # needed to know cron schedule
'pytz', # needed to manipulate timezone 'pytz', # needed to manipulate timezone
'tzlocal', # needed to manipulate timezone
'passlib', 'passlib',
'netifaces', 'netifaces',
'erp5.util', 'erp5.util',
......
...@@ -10,6 +10,7 @@ from os.path import isfile, getmtime ...@@ -10,6 +10,7 @@ from os.path import isfile, getmtime
from datetime import datetime from datetime import datetime
from croniter import croniter from croniter import croniter
from dateutil.parser import parse from dateutil.parser import parse
from tzlocal import get_localzone
class RunPromise(GenericPromise): class RunPromise(GenericPromise):
...@@ -34,7 +35,9 @@ class RunPromise(GenericPromise): ...@@ -34,7 +35,9 @@ class RunPromise(GenericPromise):
script = self.getConfig('script_fullpath') script = self.getConfig('script_fullpath')
status = self.getConfig('status_fullpath') status = self.getConfig('status_fullpath')
prev_cron = croniter(self.getConfig('cron_frequency'), datetime.now(pytz.utc)).get_prev(datetime) # date of the previous time cron launched local_tz = get_localzone()
prev_cron = croniter(self.getConfig('cron_frequency'), datetime.now()).get_prev(datetime) # date of the previous time cron launched
prev_cron = local_tz.localize(prev_cron)
status_url = "{}/private/{}/{}".format(self.getConfig("monitor_url"), self.getConfig("status_dirbasename"), self.getConfig("status_name")) status_url = "{}/private/{}/{}".format(self.getConfig("monitor_url"), self.getConfig("status_dirbasename"), self.getConfig("status_name"))
statistic_url = "{}/private/{}/{}".format(self.getConfig("monitor_url"), self.getConfig("statistic_dirbasename"), self.getConfig("statistic_name")) statistic_url = "{}/private/{}/{}".format(self.getConfig("monitor_url"), self.getConfig("statistic_dirbasename"), self.getConfig("statistic_name"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment