-import time
-#from time import datetime
-from Tools import Directories, Notifications, ASCIItranslit
-
-from Components.config import config
-import timer
-import xml.etree.cElementTree
-
from enigma import eEPGCache, getBestPlayableServiceReference, \
eServiceReference, iRecordableService, quitMainloop
-from Screens.MessageBox import MessageBox
+from Components.config import config
from Components.TimerSanityCheck import TimerSanityCheck
-import NavigationInstance
+from Screens.MessageBox import MessageBox
import Screens.Standby
-
-from time import localtime
-
+from Tools import Directories, Notifications, ASCIItranslit
from Tools.XMLTools import stringToXML
+
+import timer
+import xml.etree.cElementTree
+import NavigationInstance
from ServiceReference import ServiceReference
+from time import localtime, strftime, ctime, time
+from bisect import insort
+
# ok, for descriptions etc we have:
# service reference (to get the service name)
# name (title)
recordings = NavigationInstance.instance.getRecordings()
if not recordings: # no more recordings exist
rec_time = NavigationInstance.instance.RecordTimer.getNextRecordingTime()
- if rec_time > 0 and (rec_time - time.time()) < 360:
- print "another recording starts in", rec_time - time.time(), "seconds... do not shutdown yet"
+ if rec_time > 0 and (rec_time - time()) < 360:
+ print "another recording starts in", rec_time - time(), "seconds... do not shutdown yet"
else:
print "no starting records in the next 360 seconds... immediate shutdown"
RecordTimerEntry.shutdown() # immediate shutdown
timer.TimerEntry.__init__(self, int(begin), int(end))
if checkOldTimers == True:
- if self.begin < time.time() - 1209600:
- self.begin = int(time.time())
+ if self.begin < time() - 1209600:
+ self.begin = int(time())
if self.end < self.begin:
self.end = self.begin
self.resetState()
def log(self, code, msg):
- self.log_entries.append((int(time.time()), code, msg))
+ self.log_entries.append((int(time()), code, msg))
print "[TIMER]", msg
def calculateFilename(self):
service_name = self.service_ref.getServiceName()
- begin_date = time.strftime("%Y%m%d %H%M", time.localtime(self.begin))
+ begin_date = strftime("%Y%m%d %H%M", localtime(self.begin))
print "begin_date: ", begin_date
print "service_name: ", service_name
# we must calc nur start time before stopRecordService call because in Screens/Standby.py TryQuitMainloop tries to get
# the next start time in evEnd event handler...
self.do_backoff()
- self.start_prepare = time.time() + self.backoff
+ self.start_prepare = time() + self.backoff
NavigationInstance.instance.stopRecordService(self.record_service)
self.record_service = None
if next_state == self.StatePrepared:
if self.tryPrepare():
self.log(6, "prepare ok, waiting for begin")
+ # create file to "reserve" the filename
+ # because another recording at the same time on another service can try to record the same event
+ # i.e. cable / sat.. then the second recording needs an own extension... when we create the file
+ # here than calculateFilename is happy
+ if not self.justplay:
+ open(self.Filename + ".ts", "w").close()
# fine. it worked, resources are allocated.
self.next_activation = self.begin
self.backoff = 0
self.log(13, "start record returned %d" % record_res)
self.do_backoff()
# retry
- self.begin = time.time() + self.backoff
+ self.begin = time() + self.backoff
return False
return True
if not self.autoincrease:
return False
if entry is None:
- new_end = int(time.time()) + self.autoincreasetime
+ new_end = int(time()) + self.autoincreasetime
else:
new_end = entry.begin -30
del simulTimerList
new_end -= 30 # 30 Sekunden Prepare-Zeit lassen
del dummyentry
- if new_end <= time.time():
+ if new_end <= time():
return False
self.end = new_end
return True
self.backoff = 0
if int(old_prepare) != int(self.start_prepare):
- self.log(15, "record time changed, start prepare is now: %s" % time.ctime(self.start_prepare))
+ self.log(15, "record time changed, start prepare is now: %s" % ctime(self.start_prepare))
def gotRecordEvent(self, record, event):
# TODO: this is not working (never true), please fix. (comparing two swig wrapped ePtrs)
self.loadTimer()
except IOError:
print "unable to load timers from file!"
-
+
+ def doActivate(self, w):
+ # when activating a timer which has already passed,
+ # simply abort the timer. don't run trough all the stages.
+ if w.shouldSkip():
+ w.state = RecordTimerEntry.StateEnded
+ else:
+ # when active returns true, this means "accepted".
+ # otherwise, the current state is kept.
+ # the timer entry itself will fix up the delay then.
+ if w.activate():
+ w.state += 1
+
+ self.timer_list.remove(w)
+
+ # did this timer reached the last state?
+ if w.state < RecordTimerEntry.StateEnded:
+ # no, sort it into active list
+ insort(self.timer_list, w)
+ else:
+ # yes. Process repeated, and re-add.
+ if w.repeated:
+ w.processRepeated()
+ w.state = RecordTimerEntry.StateWaiting
+ self.addTimerEntry(w)
+ else:
+ insort(self.processed_timers, w)
+
+ self.stateChanged(w)
+
def isRecording(self):
isRunning = False
for timer in self.timer_list:
file.close()
def getNextZapTime(self):
- now = time.time()
+ now = time()
for timer in self.timer_list:
if not timer.justplay or timer.begin < now:
continue
return -1
def getNextRecordingTime(self):
- now = time.time()
+ now = time()
for timer in self.timer_list:
- print "timer", timer
next_act = timer.getNextActivation()
if timer.justplay or next_act < now:
continue
return -1
def isNextRecordAfterEventActionAuto(self):
- now = time.time()
+ now = time()
t = None
for timer in self.timer_list:
if timer.justplay or timer.begin < now:
chktimecmp_end = chktimecmp + (duration / 60)
time = localtime(x.begin)
for y in (0, 1, 2, 3, 4, 5, 6):
- if x.repeated & (2 ** y) and (x.begin <= begin or begin <= x.begin <= end):
+ if x.repeated & (1 << y) and (x.begin <= begin or begin <= x.begin <= end):
timecmp = y * 1440 + time.tm_hour * 60 + time.tm_min
if timecmp <= chktimecmp < (timecmp + ((x.end - x.begin) / 60)):
time_match = ((timecmp + ((x.end - x.begin) / 60)) - chktimecmp) * 60