Suggestion: Help me in function `_get_localzone` to get timezone data
returnWOW opened this issue · comments
There has some unknow reason on this file /etc/timezone
is empty, but right now the function _get_localzone
first to parser this file to obtain time zone info, in this case has raise UnknownTimeZoneError
.
But I saw this function has other way to get Timezone info, so we can change this func to raise error when return without Timezone. Sorry for my bad English.
File "/usr/local/ba/run.py", line 2, in <module>
from app import app
File "/usr/local/ba/app/__init__.py", line 50, in <module>
scheduler = APScheduler()
File "/usr/local/lib/python3.7/site-packages/flask_apscheduler/scheduler.py", line 36, in __init__
self._scheduler = scheduler or BackgroundScheduler()
File "/usr/local/lib/python3.7/site-packages/apscheduler/schedulers/base.py", line 87, in __init__
self.configure(gconfig, **options)
File "/usr/local/lib/python3.7/site-packages/apscheduler/schedulers/base.py", line 126, in configure
self._configure(config)
File "/usr/local/lib/python3.7/site-packages/apscheduler/schedulers/background.py", line 29, in _configure
super(BackgroundScheduler, self)._configure(config)
File "/usr/local/lib/python3.7/site-packages/apscheduler/schedulers/base.py", line 697, in _configure
self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
File "/usr/local/lib/python3.7/site-packages/tzlocal/unix.py", line 131, in get_localzone
_cache_tz = _get_localzone()
File "/usr/local/lib/python3.7/site-packages/tzlocal/unix.py", line 70, in _get_localzone
return pytz.timezone(etctz.replace(' ', '_'))
File "/usr/local/lib/python3.7/site-packages/pytz/__init__.py", line 181, in timezone
raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: ''
Well, the easiest is to just delete /etc/timezone
, or edit it, and add the correct timezone.
tzlocal is trying to find your timezone in the systems configuration. If it's incorrectly configured, tzlocal will fail in doing so.
Well, the easiest is to just delete
/etc/timezone
, or edit it, and add the correct timezone.tzlocal is trying to find your timezone in the systems configuration. If it's incorrectly configured, tzlocal will fail in doing so.
Ok, But thanks.