def startPlugin(session): if isInetAvailable(): from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.plugin import PVMCSync session.open(PVMCSync) else: from Screens.MessageBox import MessageBox session.open(MessageBox,_("No internet connection available!"), MessageBox.TYPE_INFO, timeout=10)
def checkForUpdate(self): printl("->", self, "S") if isInetAvailable(): time.sleep(2) version, remoteUrl = Update().checkForUpdate() if version is None: self.session.openWithCallback(self.callback, MessageBox,_("No update available"), MessageBox.TYPE_INFO) self.close() else: self.g_remoteUrl = remoteUrl self.session.openWithCallback(self.startUpdate, MessageBox,_("Update to revision " + version + " found!\nDo you want to update now?"), MessageBox.TYPE_YESNO) else: self.session.openWithCallback(self.close, MessageBox,_("No internet connection available!"), MessageBox.TYPE_OK)
def getUTC(): if isInetAvailable() is False: printl("Can not get utc time as no internet connection available!", __name__, "W") return None try: from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.WebGrabber import getText page = getText("http://www.time.gov/timezone.cgi?UTC/s/0", False, False) timeIndex = page.find(TIME_START) time = page[(timeIndex+len(TIME_START)):] timeIndex = time.find(TIME_END) time = time[:timeIndex] print time dateIndex = page.find(DATE_START) date = page[(dateIndex+len(DATE_START)):] dateIndex = date.find(DATE_END) date = date[:dateIndex] print date rDate = re.compile("(?P<weekday>\w+), (?P<month>\w+) (?P<day>\d+), (?P<year>\d+)") mDate = rDate.search(date) dateDict = mDate.groupdict() monthStr = dateDict["month"] month = 1 if monthStr == "February": month = 2 elif monthStr == "March": month = 3 elif monthStr == "April": month = 4 elif monthStr == "May": month = 5 elif monthStr == "June": month = 6 elif monthStr == "July": month = 7 elif monthStr == "August": month = 8 elif monthStr == "September": month = 9 elif monthStr == "October": month = 10 elif monthStr == "November": month = 11 elif monthStr == "December": month = 12 return "%s-%s-%s %s" % (dateDict["year"], month, dateDict["day"], time) except Exception, ex: printl("Exception(" + str(ex) + ")", __name__, "E")
def _setUpdateXmlDict(self): printl("->", self, "S") if isInetAvailable(): boxType = getBoxtype() self.url = config.plugins.pvmc.url.value + config.plugins.pvmc.updatexml.value installedRevision = self.getInstalledRevision() printl("Checking URL: " + str(self.url), self) try: opener = urllib2.build_opener() opener.addheaders = [('User-agent', 'urllib2_val_' + boxType[1] + '_' + boxType[2] + '_' + boxType[3] + '_' + installedRevision)] f = opener.open(self.url) html = f.read() from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.Xml2Dict import Xml2Dict updateXml = Xml2Dict("") updateXml.parse(html) self.updateXmlDict = updateXml.get() except Exception, e: printl("""Could not download HTTP Page (%s)""" % (e), self, "E")
def onExecStartScript(self): printl("->", self, "H") version = None if config.plugins.pvmc.checkforupdate.value != "Off": if isInetAvailable(): version, remoteUrl = Update().checkForUpdate() else: printl("Can not check for updates as no internet connection available!", self, "W") printl("version=" + str(version), self) if version is not None: if config.plugins.pvmc.checkforupdate.value == "Active": self.session.openWithCallback(self.startUpdate, MessageBox, \ _("A new version of MediaCenter is available for download!\n\nVersion: %s") % version, \ MessageBox.TYPE_YESNO, timeout=120, close_on_any_key=False, default=False) elif config.plugins.pvmc.checkforupdate.value == "Passive": #behind = int(version[1:]) - int(config.plugins.pvmc.version.value[1:]) #multiple = "" #if behind > 1: # multiple = (_("revisions")) #else: # multiple = (_("revision")) #self["version"].setText((_("Current Version %s.") % config.plugins.pvmc.version.value) + ' ' + (_("You are %s") % behind) + ' ' + (_("%s behind!") % multiple)) self["version"].setText(_("Update to %s available") % int(version[1:])) version = None #Hack for the moment else: version = None #Hack for the moment if version is None: # If the update dialog is being shown, dont run autostart. # If the user dont want an update the autostart will be initialised by messagebox callback self.runAutostart() printl("<-", self, "H")
def getInfoText(self): printl("->", self, "I") version = None content = "" content += "Information\n\n" content += "Find out more here - http://code.google.com/p/project-valerie/\n\n" content += "Autors: \t schischu65\n" content += "\t slugshot\n" content += "\t DonDavici\n" content += "\t Erik Fornoff\n" content += "\t Zuki\n" content += "\t hellmaster\n\n" content += "Your current version is " + config.plugins.pvmc.version.value + " " if isInetAvailable(): version, remoteUrl = Update().checkForUpdate() if version is not None: behind = int(version[1:]) - int(config.plugins.pvmc.version.value[1:]) multiple = "" if behind > 1: multiple = "s" content += (" - You are %d revision%s behind!\n") % (behind, multiple) printl("<-", self, "I") return content
def autostartPlugin(session): if isInetAvailable(): from Plugins.Extensions.PVMC.DMC_Plugins.DMC_SyncExtras.plugin import autostart autostart(session) else: printl("Can not sync as no internet connection available!", __name__, "W")