- f.write(self.epg_data + "\n")
- del f
- elif self.record_service == None:
- if event != self.EventAbort:
- print "timer record start failed, can't finish recording."
- elif event == self.EventStart:
- self.record_service.start()
- print "timer started!"
- elif event == self.EventEnd or event == self.EventAbort:
+ f.write(self.name + "\n")
+ f.write(self.description + "\n")
+ f.write(str(self.begin) + "\n")
+ f.close()
+ except:
+ self.log(4, "failed to write meta information")
+ return True
+
+ def do_backoff(self):
+ if self.backoff == 0:
+ self.backoff = 5
+ else:
+ self.backoff *= 2
+ if self.backoff > 100:
+ self.backoff = 100
+ self.log(10, "backoff: retry in %d seconds" % self.backoff)
+
+ def activate(self):
+ next_state = self.state + 1
+ self.log(5, "activating state %d" % next_state)
+
+ if next_state == self.StatePrepared:
+ if self.tryPrepare():
+ self.log(6, "prepare ok, waiting for begin")
+ # fine. it worked, resources are allocated.
+ self.next_activation = self.begin
+ self.backoff = 0
+ return True
+
+ self.log(7, "prepare failed")
+ if self.first_try_prepare:
+ self.first_try_prepare = False
+ if config.recording.asktozap.value == 0:
+ self.log(8, "asking user to zap away")
+ Notifications.AddNotificationWithCallback(self.failureCB, MessageBox, _("A timer failed to record!\nDisable TV and try again?\n"))
+ else: # zap without asking
+ self.log(9, "zap without asking")
+ self.failureCB(True)
+
+ self.do_backoff()
+ # retry
+ self.start_prepare = time.time() + self.backoff
+ return False
+ elif next_state == self.StateRunning:
+ self.log(11, "start recording")
+ record_res = self.record_service.start()
+
+ if record_res:
+ self.log(13, "start record returned %d" % record_res)
+ self.do_backoff()
+ # retry
+ self.begin = time.time() + self.backoff
+ return False
+
+ return True
+ elif next_state == self.StateEnded:
+ self.log(12, "stop recording")