From 8ae1bab112c9567ce4bbe26dee820a6dfe29daf2 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Wed, 7 Dec 2011 13:24:16 -0600 Subject: LinHES-system: include myth_status.py/.sh This program will give a very brief summary of upcoming recordings. If the system is a MBE it will be run at login and output will be displayed on the terminal. --- abs/core/LinHES-system/myth_status.py | 76 +++++++++++++++++++++++++++++++++++ abs/core/LinHES-system/myth_status.sh | 3 ++ 2 files changed, 79 insertions(+) create mode 100644 abs/core/LinHES-system/myth_status.py create mode 100644 abs/core/LinHES-system/myth_status.sh diff --git a/abs/core/LinHES-system/myth_status.py b/abs/core/LinHES-system/myth_status.py new file mode 100644 index 0000000..ce95c3e --- /dev/null +++ b/abs/core/LinHES-system/myth_status.py @@ -0,0 +1,76 @@ +#!/usr/bin/python2 +from MythTV import MythBE,MythDB,MythLog +import datetime,time,sys +try: + be=MythBE() + db = MythDB() +except: + print "Couldn't connect to MythTV service for status" + sys.exit(1) + +cursor = db.cursor() +now = datetime.datetime.now() +next_start_diff=0 + +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) + + + +a=be.getRecorderList() +header="#"*60 +print header +print "\n" +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) + +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") + + 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 "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) + +print "" +print "" +if next_start_diff == 0: + ur="No recordings are scheduled" +else: + d=(datetime.timedelta(seconds=next_start_diff)) + ur=formatTD(d) +print "The next recording starts in:\n %s" %(ur) + + + diff --git a/abs/core/LinHES-system/myth_status.sh b/abs/core/LinHES-system/myth_status.sh new file mode 100644 index 0000000..bc986ec --- /dev/null +++ b/abs/core/LinHES-system/myth_status.sh @@ -0,0 +1,3 @@ +#!/bin/bash +MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/myth_status.py + -- cgit v0.12