Change add support for freebsd /var/db/zoneinfo when getting local timezone information.

This commit is contained in:
JackDandy 2016-10-01 14:02:22 +01:00
parent 7c68ac2439
commit cd412e22e5
4 changed files with 11 additions and 1 deletions

3
.gitignore vendored
View file

@ -13,9 +13,10 @@ restore/
######################
# SB Test Related #
tests/cache/*
tests/Logs/*
tests/sickbeard.*
tests/cache.db
tests/*.db
######################
# Compiled source #

View file

@ -190,6 +190,7 @@
* Fix add custom torrent RSS
* Remove ILT torrent provider
* Update Tornado Web Server 4.3.dev1 (1b6157d) to 4.4.dev1 (c2b4d05)
* Change add support for freebsd /var/db/zoneinfo when getting local timezone information
### 0.11.15 (2016-09-13 19:50:00 UTC)

View file

@ -10,3 +10,4 @@ Libs with customisations...
/lib/requests/packages/urllib3/util/ssl_.py
/lib/tornado
/lib/tvdb/tvdb_api.py
/lib/tzlocal/unix.py

View file

@ -90,6 +90,13 @@ def _get_localzone(_root='/'):
# We found a timezone
return pytz.timezone(etctz.replace(' ', '_'))
# look for FreeBSD's /var/db/zoneinfo file, which contains the zone name and a newline.
freebsd_zoneinfo = os.path.join(_root, 'var/db/zoneinfo')
if os.path.exists(freebsd_zoneinfo):
with open(freebsd_zoneinfo, 'rt') as tzfile:
data = tzfile.read().strip()
return pytz.timezone(data)
# systemd distributions use symlinks that include the zone name,
# see manpage of localtime(5) and timedatectl(1)
tzpath = os.path.join(_root, 'etc/localtime')