summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/myth_status.py
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2018-06-17 17:08:23 (GMT)
committerBritney Fransen <brfransen@gmail.com>2018-06-17 17:08:23 (GMT)
commitbef1f269596c44d6f7cdfbfc1bfa220061866a29 (patch)
treee8ab73c7ebd273b9d97a5d3eb1074c0d190b6658 /abs/core/LinHES-system/myth_status.py
parentb36d08a3d75a3093bf2e174ad5ba49ab4cace160 (diff)
downloadlinhes_pkgbuild-bef1f269596c44d6f7cdfbfc1bfa220061866a29.zip
linhes_pkgbuild-bef1f269596c44d6f7cdfbfc1bfa220061866a29.tar.gz
linhes_pkgbuild-bef1f269596c44d6f7cdfbfc1bfa220061866a29.tar.bz2
LinHES-system: myth_status.py: adjust timezone for date math
Diffstat (limited to 'abs/core/LinHES-system/myth_status.py')
-rw-r--r--abs/core/LinHES-system/myth_status.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/abs/core/LinHES-system/myth_status.py b/abs/core/LinHES-system/myth_status.py
index 0662f79..fbf8fdc 100644
--- a/abs/core/LinHES-system/myth_status.py
+++ b/abs/core/LinHES-system/myth_status.py
@@ -3,9 +3,10 @@
#Also will display alerts generated by xymon. If the location of xymon changes, this script needs to be updated.
from MythTV import MythBE,MythDB,MythLog
-import datetime,time,sys,subprocess,re
+import datetime,pytz,re,subprocess,sys,time
from dateutil.parser import parse
-from dateutil import tz
+from tzlocal import get_localzone
+
import os,glob
from socket import gethostname;
@@ -110,7 +111,8 @@ def print_alerts():
class tuner_recording_status:
def __init__ (self,num_upcoming):
- self.now = datetime.datetime.now()
+ self.now = datetime.datetime.now(pytz.utc)
+ self.currTZ = get_localzone()
self.farout=99999999
self.next_start_diff=datetime.timedelta(self.farout)
self.num_upcoming=num_upcoming
@@ -176,7 +178,6 @@ class tuner_recording_status:
a=self.be.getUpcomingRecordings()
r=0
- currTZ = tz.tzlocal()
for i in a:
r += 1
if r > self.num_upcoming:
@@ -184,14 +185,11 @@ class tuner_recording_status:
title_chan="%s (%s)" %(i.title, i.channame)
# convert timezone to local timezone
start_time=parse(str(i.starttime))
- start_time=start_time.astimezone(currTZ)
+ start_time=start_time.astimezone(self.currTZ)
start_time_out=start_time.strftime("%a %b %d %I:%M%p")
self.upcoming_list.append([start_time_out,i.hostname, title_chan])
- #remove timezone
- start_time=re.split("[-+]\d\d:\d\d",str(i.starttime))[0]
- start_time_struct=datetime.datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S")
- diff = start_time_struct - self.now
+ diff = start_time - self.now
if diff < self.next_start_diff :
self.next_start_diff = diff
@@ -230,13 +228,12 @@ class tuner_recording_status:
def conflicts(self):
a=self.be.getConflictedRecordings()
- currTZ = tz.tzlocal()
for i in a:
out_line=''
title_chan="%s (%s)" %(i.title, i.channame)
# convert timezone to local timezone
start_time=parse(str(i.starttime))
- start_time=start_time.astimezone(currTZ)
+ start_time=start_time.astimezone(self.currTZ)
start_time_out=start_time.strftime("%a %b %d %I:%M%p")
out_line=(start_time_out,i.hostname,title_chan)
self.conflict_list.append(out_line)