2 from Components.config import ConfigYesNo, NoSave
5 from Plugins.Extensions.PushService.__init__ import _
6 from Plugins.Extensions.PushService.PluginBase import PluginBase
9 import NavigationInstance
10 from time import localtime, strftime
13 SUBJECT = _("Record Summary")
14 BODY = _("Finished record list:\n%s")
15 TAG = _("FinishedTimerPushed")
18 class RecordSummary(PluginBase):
20 ForceSingleInstance = True
23 # Is called on instance creation
24 PluginBase.__init__(self)
27 # Default configuration
28 self.setOption( 'remove_timer', NoSave(ConfigYesNo( default = False )), _("Remove finished timer(s) only after ") )
31 # Return Header, Body, Attachment
32 # If empty or none is returned, nothing will be sent
33 # Search finished timers
36 for timer in NavigationInstance.instance.RecordTimer.processed_timers:
37 if not timer.disabled and TAG not in timer.tags:
38 text += str(timer.name) + "\t" \
39 + strftime(_("%Y.%m.%d %H:%M"), localtime(timer.begin)) + " - " \
40 + strftime(_("%H:%M"), localtime(timer.end)) + "\t" \
41 + str(timer.service_ref and timer.service_ref.getServiceName() or "") \
43 self.timers.append( timer )
44 if self.timers and text:
45 return SUBJECT, BODY % text
51 # Called after successful sending the message
52 if self.getValue('remove_timer'):
53 # Remove finished timers
54 for timer in self.timers[:]:
55 if timer in NavigationInstance.instance.RecordTimer.processed_timers:
56 NavigationInstance.instance.RecordTimer.processed_timers.remove(timer)
57 self.timers.remove(timer)
59 # Set tag to avoid resending it
60 for timer in self.timers[:]:
61 timer.tags.append(TAG)
62 NavigationInstance.instance.RecordTimer.saveTimer()
63 self.timers.remove(timer)
66 # Called after message sent has failed