def onRecordEvent(self, timer): text = "" if timer.justplay: pass elif timer.state == timer.StatePrepared: pass elif timer.state == timer.StateRunning: if self.getValue('send_on_start'): text += _("Record started:\n") \ + str(timer.name) + " " \ + strftime(_("%Y.%m.%d %H:%M"), localtime(timer.begin)) + " - " \ + strftime(_("%H:%M"), localtime(timer.end)) + " " \ + str(timer.service_ref and timer.service_ref.getServiceName() or "") del timer # Finished repeating timer will report the state StateEnded+1 or StateWaiting elif timer.state == timer.StateEnded or timer.repeated and timer.state == timer.StateWaiting: if self.getValue('send_on_end'): text += _("Record finished:\n ") \ + str(timer.name) + "\t" \ + strftime(_("%Y.%m.%d %H:%M"), localtime(timer.begin)) + " - " \ + strftime(_("%H:%M"), localtime(timer.end)) + "\t" \ + str(timer.service_ref and timer.service_ref.getServiceName() or "") del timer if text: #TODO Problem test tun won't get the message # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, text)
def onRecordEvent(self, timer): text = "" if timer.justplay: pass elif timer.state == timer.StatePrepared: pass elif timer.state == timer.StateRunning: if self.getValue('send_on_start'): text += _("Record started:\n") \ + str(timer.name) + " " \ + strftime(_("%Y.%m.%d %H:%M"), localtime(timer.begin)) + " - " \ + strftime(_("%H:%M"), localtime(timer.end)) + " " \ + str(timer.service_ref and timer.service_ref.getServiceName() or "") del timer # Finished repeating timer will report the state StateEnded+1 or StateWaiting elif timer.state == timer.StateEnded or timer.repeated and timer.state == timer.StateWaiting: if self.getValue('send_on_end'): text += _("Record finished:\n ") \ + str(timer.name) + "\t" \ + strftime(_("%Y.%m.%d %H:%M"), localtime(timer.begin)) + " - " \ + strftime(_("%H:%M"), localtime(timer.end)) + "\t" \ + str(timer.service_ref and timer.service_ref.getServiceName() or "") del timer if text: #TODO Problem test run won't get the message # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, text)
def end(self): # Is called after stopping PushSerive if self.getValue('send_before_shutdown'): text = _("Enigma2 shutdown initiated") # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, text)
def leaveStandby(self, dummy=None): #log.debug( "leave standby" ) if self.getValue('send_after_standby'): text = _("Enigma2 wakeup after Standby") # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, text)
def standbyCountChanged(self, configElement=None): #log.debug( "enter standby num", configElement.value ) from Screens.Standby import inStandby inStandby.onClose.append(self.leaveStandby) if self.getValue('send_before_standby'): text = _("Enigma2 going into Standby") # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, text)
def begin(self): # Is called after starting PushService if self.getValue('send_after_bootup'): text = _("Enigma2 booted") # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, text) from Components.config import config config.misc.standbyCounter.addNotifier(self.standbyCountChanged, initial_call = False)
def begin(self): # Is called after starting PushService if self.getValue('send_after_bootup'): text = _("Enigma2 booted") # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, text) from Components.config import config config.misc.standbyCounter.addNotifier(self.standbyCountChanged, initial_call=False)
class OPKGUpdateNotification(ControllerBase): ForceSingleInstance = True def __init__(self): # Is called on instance creation ControllerBase.__init__(self) # Default configuration self.setOption('selfcheck', NoSave(ConfigYesNo(default=False)), _("Start update check if not done yet")) self.data = "" self.container = eConsoleAppContainer() try: self.container_dataAvail_conn = self.container.dataAvail.connect( self.dataAvail) except: self.container_dataAvail_conn = None self.container.dataAvail.append(self.dataAvail) try: self.container_appClosed_conn = self.container.appClosed.connect( self.opkgupgradableFinished) except: self.container_appClosed_conn = None self.container.appClosed.append(self.opkgupgradableFinished) def run(self, callback, errback): self.data = "" self.opkgupgradable() callback() def dataAvail(self, string): self.data += string def opkgupgradable(self): if self.getValue('selfcheck'): self.container.execute("opkg update && opkg list-upgradable") else: self.container.execute("opkg list-upgradable") def opkgupgradableFinished(self, retval=None): try: print "PushService retval: ", str(retval) except: pass try: print "PushService self.data: ", str(self.data) except: pass updates = "" if self.data: try: for line in self.data.split("\n"): print "PushService opkg upgradable data: ", line if line.startswith("Inflating"): continue if line.startswith("Updated"): continue if line.startswith("Downloading"): continue if line.startswith("Ign "): continue if line.startswith("Get:"): continue if line.startswith("Hit "): continue if line.startswith("Fetched "): continue if line.startswith("Reading "): continue if line.startswith("Err "): continue if line.find('404 ') != -1: continue if line.find('Failed ') != -1: continue if line.find('failed ') != -1: continue if line == '': continue updates += line + "\r\n" except Exception, e: updates += "\r\n\r\nException:\r\n" + str(e) print "PushService except: ", str(e) if updates: #callback( SUBJECT, BODY % (updates) ) #TODO Problem test run won't get the message # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, BODY % (updates))
class APTUpdateNotification(ControllerBase): ForceSingleInstance = True def __init__(self): # Is called on instance creation ControllerBase.__init__(self) # Default configuration self.setOption( 'selfcheck', NoSave(ConfigYesNo( default = False )), _("Start update check if not done yet") ) self.data = "" self.container = eConsoleAppContainer() try: self.container_dataAvail_conn = self.container.dataAvail.connect(self.dataAvail) except: self.container_dataAvail_conn = None self.container.dataAvail.append(self.dataAvail) try: self.container_appClosed_conn = self.container.appClosed.connect(self.aptupgradableFinished) except: self.container_appClosed_conn = None self.container.appClosed.append(self.aptupgradableFinished) def run(self, callback, errback): self.data = "" self.opkgupgradable() callback() def dataAvail(self, string): self.data += string def opkgupgradable(self): if self.getValue('selfcheck'): self.container.execute("apt update && apt-get --just-print upgrade") else: self.container.execute("apt-get --just-print upgrade") def aptupgradableFinished(self, retval=None): try: log.debug( "PushService retval: ",str(retval) ) except: pass try: log.debug( "PushService self.data: ",str(self.data) ) except: pass updates = "" excepts = "" if self.data: try: for line in self.data.split("\n"): log.debug( "PushService opkg upgradable data: ",line ) if line.startswith("Inst"): updates += line[5:] + "\r\n" continue except Exception, e: excepts += "\r\n\r\nException:\r\n" + str(e) if excepts: log.exception( excepts ) if updates: #callback( SUBJECT, BODY % (updates) ) #TODO Problem test run won't get the message # Push mail from Plugins.Extensions.PushService.plugin import gPushService if gPushService: gPushService.push(self, SUBJECT, BODY % (updates))