From e54fcad792391e6af7b2dd7872f44d95c48fbd26 Mon Sep 17 00:00:00 2001 From: Britney Fransen Date: Mon, 27 Mar 2017 15:56:37 +0000 Subject: LinHES-system: myth_status.py: convert timezone pulled from db to local --- abs/core/LinHES-system/PKGBUILD | 6 ++-- abs/core/LinHES-system/myth_status.py | 54 ++++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 81b72a3..3de7853 100755 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,13 +1,13 @@ pkgname=LinHES-system pkgver=8.4 -pkgrel=23 +pkgrel=24 arch=('i686' 'x86_64') install=system.install pkgdesc="Everything that makes LinHES an automated system" license=('GPL2') depends=('linhes-sounds' 'xdotool' 'tilda' 'keylaunch' 'dvdbackup' 'python_aosd' 'udisks' 'LinHES-config>=2.3-59' 'sudo' - 'python2-dbus' 'unclutter' 'wmctrl' 'archlinux-xdg-menu' + 'python2-dateutil' 'python2-dbus' 'unclutter' 'wmctrl' 'archlinux-xdg-menu' 'ethtool' 'gnu-netcat' 'normalize' 'ttf-overlock' 'handbrake-cli' 'mkvtoolnix-cli' 'mplayer' 'runit-scripts>=8.1-12') backup=('etc/modprobe.d/alsa-base.conf' 'etc/X11/autostart/autostart.run') @@ -90,7 +90,7 @@ md5sums=('c6e6b83a1f4c35ef4501e277657ab2ac' '542e670e78d117657f93141e9689f54d' '8da6a7f1703a002f84e66629e847d8a6' 'bb72ab230c7a71706285bd0f31a4fb1f' - 'f8683caddf74dca1ea5cc3db4d748764' + '7cc012ad0e71b40b4a376ab33a33c1cd' '962a3e9eaba2d1466251b7ab0956705d' '1758aed160de64abfafb28a3a8f3390e' '33fbebbd546672cedd3c5e7350ab414e' diff --git a/abs/core/LinHES-system/myth_status.py b/abs/core/LinHES-system/myth_status.py index 40dd3b3..0662f79 100644 --- a/abs/core/LinHES-system/myth_status.py +++ b/abs/core/LinHES-system/myth_status.py @@ -4,6 +4,8 @@ from MythTV import MythBE,MythDB,MythLog import datetime,time,sys,subprocess,re +from dateutil.parser import parse +from dateutil import tz import os,glob from socket import gethostname; @@ -48,7 +50,7 @@ def print_alerts(): #print " myth_status: Couldn't change dir to %s" %dir_name file_list=glob.glob("*") - + if len(file_list) == 0: #print " myth_status: no alert files found" pass @@ -67,13 +69,13 @@ def print_alerts(): except: #print " myth_status: Couldn't open %s for reading" %alert_file continue - + for line in lines: try: data,value=line.split(":") except: continue #exception occured try the next line - + if data == 'HOST': datahost = value.strip() elif data == 'SERVICE': @@ -85,21 +87,21 @@ def print_alerts(): sec=int(datadown) td_sec = datetime.timedelta(seconds=sec) td_sec_formated = formatTD(td_sec) - + out_line =" %s on %s %s for %s \n" %(dataservice, datahost,datacolor.upper(), td_sec_formated) out_alert += out_line - + print "System Alerts:" print "--------------" if len(out_alert) > 0: - print out_alert + print out_alert print " Go to http://%s and click Health & Maintenance for more information." %gethostname() else: print " All systems OK" - return + return #------------------------------------------- @@ -107,7 +109,7 @@ def print_alerts(): class tuner_recording_status: def __init__ (self,num_upcoming): - + self.now = datetime.datetime.now() self.farout=99999999 self.next_start_diff=datetime.timedelta(self.farout) @@ -124,7 +126,7 @@ class tuner_recording_status: def get_db_check_status(self): return self.db_connection_status - + def check_database_connection(self): rc=0 try: @@ -160,7 +162,7 @@ class tuner_recording_status: def get_tuner_status(self): return self.tuner_status - + def print_tuner_status(self): print "Tuner Status:" print "-------------" @@ -169,24 +171,26 @@ class tuner_recording_status: print line else: print " No tuners found" - #-------- def upcoming_recordings(self): - + a=self.be.getUpcomingRecordings() r=0 + currTZ = tz.tzlocal() for i in a: r += 1 if r > self.num_upcoming: break - 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_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") - start_time_out=start_time_struct.strftime("%a %b %d %I:%M%p") - self.upcoming_list.append([start_time_out,i.hostname, title_chan]) - #print " %s - %s - %s" %(start_time_out,i.hostname, title_chan) + diff = start_time_struct - self.now if diff < self.next_start_diff : self.next_start_diff = diff @@ -195,11 +199,10 @@ class tuner_recording_status: self.ur="No recordings are scheduled" else: self.ur=formatTD(self.next_start_diff) - def get_upcoming_recordings(self): return self.upcoming_list - + def print_upcoming_recordings(self): #print self.get_upcoming_recordings() print "" @@ -215,34 +218,39 @@ class tuner_recording_status: def get_next_start_time(self): return self.ur - + def print_next_start_time(self): print "" print "The next recording starts in:" print "-----------------------------" print " %s" %(self.get_next_start_time()) print "" - + #----- def conflicts(self): a=self.be.getConflictedRecordings() + currTZ = tz.tzlocal() for i in a: out_line='' title_chan="%s (%s)" %(i.title, i.channame) - out_line=(i.starttime,title_chan) + # convert timezone to local timezone + start_time=parse(str(i.starttime)) + start_time=start_time.astimezone(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) def get_conflict_list(self): return self.conflict_list - + def print_conflict_list(self): print "" print "Recording Conflicts:" print "--------------------" if len(self.get_conflict_list()) > 0: for i in self.get_conflict_list(): - print " %s - %-50s " %(i[0],i[1]) + print " %s - %s - %s" %(i[0],i[1],i[2]) else: print " No conflicts" -- cgit v0.12