From d41f98819d31de4611368109eb5e841700dc6722 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Tue, 24 Jan 2012 13:21:45 -0600 Subject: linhes-system: myth-status.sh / .py Modify the shell script so that it only runs once per session Modify the python script for formatting Modify the python script to fix a bug when the next recording is more then 24 hours out. Anything more then 24 hours and the program would not account for it. --- abs/core/LinHES-system/PKGBUILD | 6 +-- abs/core/LinHES-system/myth_status.py | 99 ++++++++++++++++++++++------------- abs/core/LinHES-system/myth_status.sh | 7 ++- 3 files changed, 73 insertions(+), 39 deletions(-) diff --git a/abs/core/LinHES-system/PKGBUILD b/abs/core/LinHES-system/PKGBUILD index 80a449f..6e3649e 100644 --- a/abs/core/LinHES-system/PKGBUILD +++ b/abs/core/LinHES-system/PKGBUILD @@ -1,6 +1,6 @@ pkgname=LinHES-system pkgver=2 -pkgrel=34 +pkgrel=36 arch=('i686') MVDIR=$startdir/pkg/usr/LH BINDIR=$startdir/pkg/usr/bin @@ -62,8 +62,8 @@ md5sums=('d6a564f3286590875874573107940908' 'abe887472a170bd1a8e6da6a7b7e93e4' '752488eb8bfb672ce0e4c924f7faf3d1' 'ba351b92e69bcaf26a9bf80417b09c3c' - '361bf81a6a117d61c3bc32dda91c4cb9' - 'ce72aad1fc66c575f863d4bfbf65ce16' + '60219aab8a177c783d7a658d56683db4' + '962a3e9eaba2d1466251b7ab0956705d' 'd03aedeeeda0f5e9c1eb437411c88477' '94ce8f1d5085c0db7b267db8c2e9a3ff' '3db82bd7b9234fc941e4a53b464e0d46' diff --git a/abs/core/LinHES-system/myth_status.py b/abs/core/LinHES-system/myth_status.py index ce95c3e..4e44fd5 100644 --- a/abs/core/LinHES-system/myth_status.py +++ b/abs/core/LinHES-system/myth_status.py @@ -10,67 +10,96 @@ except: cursor = db.cursor() now = datetime.datetime.now() -next_start_diff=0 +farout=99999999 +next_start_diff=datetime.timedelta(farout) -def formatTD(td): - hours = td.seconds // 3600 - minutes = (td.seconds % 3600) // 60 - seconds = td.seconds % 60 - return '%s hours, %s minutes, %s seconds' % (hours, minutes, seconds) +def formatTD(td): + #print td + days = td.days + hours = td.seconds // 3600 + minutes = (td.seconds % 3600) // 60 + seconds = td.seconds % 60 + + if days > 1: + day_string = "%s days" %days + else: + day_string = "%s day" %days + + if hours > 1: + hour_string = "%s hours" %hours + else: + hour_string = "%s hour" %hours + + if minutes > 1: + minute_string = "%s minutes" %minutes + else: + minute_string = "%s minute" %minutes + + if seconds > 1: + second_string = "%s seconds" %seconds + else: + second_string = "%s second" %seconds + + return_string = '%s, %s, %s, %s' % (day_string, hour_string, minute_string, second_string) + return return_string a=be.getRecorderList() header="#"*60 print header -print "\n" +print "" print "Tuner Status: " print "--------------" for i in a: - cmd="select cardtype,hostname from capturecard where cardid=%s;" %i - - cursor.execute(cmd) - results=cursor.fetchall() - type = results[0][0] - hostname = results[0][1] - id = i - c=be.getCurrentRecording(i) - if c.title == None: - current_recording = "Idle" - else: - current_recording = "Recording %s" %c.title - print " Tuner %s (%s) on %s : %s " %(id, type, hostname, current_recording) + cmd="select cardtype,hostname from capturecard where cardid=%s;" %i + + cursor.execute(cmd) + results=cursor.fetchall() + type = results[0][0] + hostname = results[0][1] + id = i + c=be.getCurrentRecording(i) + if c.title == None: + current_recording = "Idle" + else: + current_recording = "Recording %s" %c.title + print " Tuner %s (%s) on %s : %s " %(id, type, hostname, current_recording) + print "" print "Upcoming Recordings:" print "--------------------" a=be.getUpcomingRecordings() for i in a: - title_chan="%s (%s)" %(i.title, i.channame) - print " %s - %s - %-50s " %(i.starttime,i.hostname, title_chan) - #start_time=time.strptime(str(i.starttime), "%Y-%m-%d %H:%M:%S") + title_chan="%s (%s)" %(i.title, i.channame) + print " %s - %s - %-50s " %(i.starttime,i.hostname, title_chan) + #start_time=time.strptime(str(i.starttime), "%Y-%m-%d %H:%M:%S") + diff = i.starttime - now + if diff < next_start_diff : + next_start_diff = diff - diff = i.starttime - now -# print diff.seconds - if diff.seconds < next_start_diff or next_start_diff == 0: - next_start_diff = diff.seconds -print " " +print "" print "Conflicted Recordings:" print "----------------------" a=be.getConflictedRecordings() -for i in a: - title_chan="%s (%s)" %(i.title, i.channame) - print " %s - %-50s " %(i.starttime,title_chan) +if len(a) == 0: + print " No conflicts" +else: + for i in a: + title_chan="%s (%s)" %(i.title, i.channame) + print " %s - %-50s " %(i.starttime,title_chan) print "" print "" -if next_start_diff == 0: + + +if next_start_diff == datetime.timedelta(farout): ur="No recordings are scheduled" else: - d=(datetime.timedelta(seconds=next_start_diff)) - ur=formatTD(d) + ur=formatTD(next_start_diff) print "The next recording starts in:\n %s" %(ur) +print "" - diff --git a/abs/core/LinHES-system/myth_status.sh b/abs/core/LinHES-system/myth_status.sh index bc986ec..f942c64 100644 --- a/abs/core/LinHES-system/myth_status.sh +++ b/abs/core/LinHES-system/myth_status.sh @@ -1,3 +1,8 @@ #!/bin/bash -MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/myth_status.py +if [ x$MYTH_RUN_STATUS = x ] +then + MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/myth_status.py +fi +MYTH_RUN_STATUS="1" + -- cgit v0.12