1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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)
|