summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-system/myth_status.py
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-01-24 19:21:45 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-01-24 19:21:45 (GMT)
commitd41f98819d31de4611368109eb5e841700dc6722 (patch)
treee7c323cc64dc0bccc89acdddfcd3c416ded6f2f7 /abs/core/LinHES-system/myth_status.py
parent2d450e59e2878ac5eae558840c9c86ab2b7ba9bf (diff)
downloadlinhes_pkgbuild-d41f98819d31de4611368109eb5e841700dc6722.zip
linhes_pkgbuild-d41f98819d31de4611368109eb5e841700dc6722.tar.gz
linhes_pkgbuild-d41f98819d31de4611368109eb5e841700dc6722.tar.bz2
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.
Diffstat (limited to 'abs/core/LinHES-system/myth_status.py')
-rw-r--r--abs/core/LinHES-system/myth_status.py99
1 files changed, 64 insertions, 35 deletions
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 ""
-