2 from Components.config import ConfigYesNo, ConfigText, ConfigNumber, NoSave
5 from Plugins.Extensions.PushService.__init__ import _
6 from Plugins.Extensions.PushService.PluginBase import PluginBase
11 from Plugins.SystemPlugins.SoftwareManager.SoftwareTools import iSoftwareTools
14 SUBJECT = _("IPKG Update Notification")
15 BODY = _("There are updates available:\n%s")
18 class IPKGUpdateNotification(PluginBase):
20 ForceSingleInstance = True
23 # Is called on instance creation
24 PluginBase.__init__(self)
26 # Default configuration
27 self.setOption( 'selfcheck', NoSave(ConfigYesNo( default = False )), _("Start update check if not done yet") )
30 # Return Header, Body, Attachment
31 # If empty or none is returned, nothing will be sent
32 # Adapted from Software Manager
33 if iSoftwareTools.lastDownloadDate is not None and iSoftwareTools.lastDownloadDate > ( time() - (24*60*60) ):
34 # Last refresh was within one day
35 updates = self.buildList()
37 return SUBJECT, BODY % (updates)
39 print "IPKGUpdateNotification run else"
40 if self.getValue('selfcheck'):
41 # Refresh package list
42 iSoftwareTools.startSoftwareTools(self.getUpdateInfosCB)
45 def getUpdateInfosCB(self, retval = None):
46 if retval is not None:
48 if iSoftwareTools.available_updates is not 0:
49 # _("There are at least ") + str(iSoftwareTools.available_updates) + _(" updates available.")
50 print "Updates available."
51 return self.buildList()
53 # _("There are no updates available.")
54 print "There are no updates available."
57 if iSoftwareTools.lastDownloadDate is None:
58 if iSoftwareTools.NetworkConnectionAvailable:
59 # _("Updatefeed not available.")
60 print "Updatefeed not available."
63 # _("No network connection available.")
64 print "No network connection available."
67 print "IPKGUpdateNotification getUpdates"
69 iSoftwareTools.lastDownloadDate = time()
70 iSoftwareTools.list_updating = True
71 iSoftwareTools.getUpdates(self.getUpdateInfosCB)
76 for package in iSoftwareTools.available_updatelist:
77 packagename = package[0]
79 if packagename in iSoftwareTools.installed_packetlist:
80 instversion = iSoftwareTools.installed_packetlist[packagename]
82 for p, v, d in iSoftwareTools.available_packetlist:
86 updates += packagename + " :\t" + instversion + " :\t" + updversion + "\n"