From 8a2610aa8482acb04e9b331aafd8e2230c623991 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 23 Mar 2011 22:14:57 -0400 Subject: [PATCH] CC-1894: Warn users about time zone differences or clock drift problems on the server -Now using timezone offsets from UTC instead of regions to compare timezones between pypo and the airtime webserver --- application/models/Schedule.php | 2 +- pypo/pypofetch.py | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/application/models/Schedule.php b/application/models/Schedule.php index aaff58ef9..ba5b97290 100644 --- a/application/models/Schedule.php +++ b/application/models/Schedule.php @@ -716,7 +716,7 @@ class Schedule { $result['stream_metadata'] = array(); $result['stream_metadata']['format'] = Application_Model_Preference::GetStreamLabelFormat(); $result['stream_metadata']['station_name'] = Application_Model_Preference::GetStationName(); - $result['server_timezone'] = date_default_timezone_get(); + $result['server_timezone'] = date('O'); return $result; } diff --git a/pypo/pypofetch.py b/pypo/pypofetch.py index 0313e9567..2958c6bd4 100644 --- a/pypo/pypofetch.py +++ b/pypo/pypofetch.py @@ -11,6 +11,7 @@ import json import telnetlib import math from threading import Thread +from subprocess import Popen, PIPE # For RabbitMQ from kombu.connection import BrokerConnection @@ -78,13 +79,14 @@ class PypoFetch(Thread): def check_matching_timezones(self, server_timezone): logger = logging.getLogger('fetch') - f = open('/etc/timezone', 'r') - pypo_timezone = f.readline().strip(' \t\n\r') - f.close() + + process = Popen(["date", "+%z"], stdout=PIPE) + pypo_timezone = (process.communicate()[0]).strip(' \r\n\t') + if server_timezone != pypo_timezone: - logger.error("Server and pypo timezones do not match. Audio playback may not start when expected!") - logger.error("Server timezone: %s", server_timezone) - logger.error("Pypo timezone: %s", pypo_timezone) + logger.error("Server and pypo timezone offsets do not match. Audio playback may not start when expected!") + logger.error("Server timezone offset: %s", server_timezone) + logger.error("Pypo timezone offset: %s", pypo_timezone) """ Process the schedule