Merge pull request #1329 from samwiseg00/add/timezone_log

Determine system timezone, log the timezone, and display it in the web ui config table
This commit is contained in:
JonnyWong16
2018-10-23 22:05:06 -07:00
committed by GitHub
3 changed files with 20 additions and 0 deletions

View File

@@ -28,9 +28,12 @@ import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib'))
import argparse
import datetime
import locale
import pytz
import signal
import time
import tzlocal
import plexpy
from plexpy import config, database, logger, webstart
@@ -106,6 +109,14 @@ def main():
logger.initLogger(console=not plexpy.QUIET, log_dir=False,
verbose=plexpy.VERBOSE)
try:
plexpy.SYS_TIMEZONE = str(tzlocal.get_localzone())
plexpy.SYS_UTC_OFFSET = datetime.datetime.now(pytz.timezone(plexpy.SYS_TIMEZONE)).strftime('%z')
except (pytz.UnknownTimeZoneError, LookupError, ValueError) as e:
logger.error("Could not determine system timezone. %s" % e)
plexpy.SYS_TIMEZONE = 'Unknown'
plexpy.SYS_UTC_OFFSET = '+0000'
if os.getenv('TAUTULLI_DOCKER', False) == 'True':
plexpy.DOCKER = True

View File

@@ -71,6 +71,10 @@ DOCUMENTATION :: END
<td>Platform:</td>
<td>${common.PLATFORM} ${common.PLATFORM_RELEASE} (${common.PLATFORM_VERSION + (' - {}'.format(common.PLATFORM_LINUX_DISTRO) if common.PLATFORM_LINUX_DISTRO else '')})</td>
</tr>
<tr>
<td>System Timezone:</td>
<td>${plexpy.SYS_TIMEZONE} (${'UTC{}'.format(plexpy.SYS_UTC_OFFSET)})
</tr>
<tr>
<td>Python Version:</td>
<td>${sys.version}</td>

View File

@@ -110,6 +110,8 @@ TRACKER = None
WIN_SYS_TRAY_ICON = None
SYS_TIMEZONE = None
SYS_UTC_OFFSET = None
def initialize(config_file):
with INIT_LOCK:
@@ -157,6 +159,9 @@ def initialize(config_file):
common.PLATFORM, common.PLATFORM_RELEASE, common.PLATFORM_VERSION,
' - {}'.format(common.PLATFORM_LINUX_DISTRO) if common.PLATFORM_LINUX_DISTRO else ''
))
logger.info(u"{} (UTC{})".format(
plexpy.SYS_TIMEZONE, plexpy.SYS_UTC_OFFSET
))
logger.info(u"Python {}".format(
sys.version
))