def __init__(self, session): self.session = session Screen.__init__(self, session) self["sort"] = Label() self.sort = "screens" self.url = metrixDefaults.URL_GET_SUITES self["menu"] = CategoryList([]) self.CategoryListEntry(_("Loading...")) self["actions"] = ActionMap(["OkCancelActions","DirectionActions", "InputActions", "ColorActions"], { "right": self.pageDown, "left": self.pageUp, "up": self.keyUp, "upRepeated": self.keyUp, "ok": self.go, "blue": self.changeSort, "down": self.keyDown, "downRepeated": self.keyDown, "cancel": self.exit}, -1) self.setTitle("OpenStore") self["title"] = Label(_("MyMetrix // OpenStore")) menu = [] menu.append(self.CategoryListEntry(_("Loading..."))) metrixTools.callOnMainThread(self.setList,menu) self["menu"].setList(menu) self.onLayoutFinish.append(self.changeSort)
def generateSkin(self): screennames = [] screennames = self.getSkinPartsScreennames(config.plugins.MyMetrix.SkinPartPath.value + "screens/active/") metrixTools.callOnMainThread(self["output"].setText,_("Reading template file")) skindom = parse(config.plugins.MyMetrix.Templates.value) skinNode = skindom.getElementsByTagName('skin')[0] metrixTools.callOnMainThread(self["output"].setText,_("Setting colors")) self.setColor(skinNode) for screen in skindom.getElementsByTagName('screen'): screenname = str(screen.getAttributeNode('name').nodeValue) metrixTools.callOnMainThread(self["output"].setText,(str(_("Checking screen ")+screenname))) if screenname in screennames: metrixTools.callOnMainThread(self["output"].setText,_(str("Removing default screen "+screenname))) parentNode = screen.parentNode parentNode.removeChild(screen) if config.plugins.MyMetrix.CleanInfoBar.value: if screenname == "InfoBar" or screenname == "SecondInfoBar": for child in screen.childNodes: screen.removeChild(child) # APPEND STORE SCREENS path = config.plugins.MyMetrix.SkinPartPath.value + "screens/active/" dirs = listdir(path) for dir in dirs: metrixTools.callOnMainThread(self["output"].setText,_("Parsing SkinPart Screens")) try: screen = metrix_SkinPartTools.parseSkinPart(path+dir,"data.xml","config.cfg",screenname) customscreen = skindom.importNode(screen, True) skinNode.appendChild(customscreen) except Exception, e: metrixTools.log("Error appending screen",e)
def syncStart(session): global global_session global_session = session #resetting config values config.plugins.MetrixUpdater.Reboot.value = 0 config.plugins.MetrixUpdater.UpdateAvailable.value = 0 config.plugins.MetrixUpdater.Open.value = 0 config.plugins.MetrixUpdater.save() config.plugins.MyMetrix.XPiconsOverwrite.value = False config.plugins.MyMetrix.save() threadUpdater = threading.Thread(target=syncHourly, args=()) threadUpdater.daemon = True threadUpdater.start() threadUpdaterGeneral = threading.Thread(target=syncGeneral, args=()) threadUpdaterGeneral.daemon = True threadUpdaterGeneral.start() threadUpdaterDaily = threading.Thread(target=daily, args=()) threadUpdaterDaily.daemon = True threadUpdaterDaily.start() threadActions = threading.Thread(target=syncActions, args=()) threadActions.daemon = True threadActions.start() try: if config.plugins.MyMetrix.showFirstRun.value: metrixTools.callOnMainThread(Notifications.AddNotification,metrix_Intro.OpenScreen) except: pass
def changeSort(self): if self.sort == "suite": self.sort = "screens" self.url = metrixDefaults.URL_GET_SCREENS self["sort"].setText(_("Screens")) else: self.sort = "suite" self.url = metrixDefaults.URL_GET_SUITES self["sort"].setText(_("Suites")) #self.getCategories() metrixTools.callOnMainThread(self.getCategories)
def threadworker(self): while self.finished == False: if self.getCatalog == True: self.getCatalog = False self.getDesigns() if self.getEntry == True: self.getEntry = False returnValue = self.currentname self.picPath = metrixTools.webPixmap(self.screenshotpath + returnValue) # print returnValue metrixTools.callOnMainThread(self.refreshMeta) time.sleep(1)
def threadworker(self): while (self.finished == False): if self.getCatalog == True: self.getCatalog = False self.getDesigns() if self.getEntry == True: self.getEntry = False returnValue = self.currentname self.picPath = metrixTools.webPixmap(self.screenshotpath + returnValue) #print returnValue metrixTools.callOnMainThread(self.refreshMeta) time.sleep(1)
def generateSkin(self): screennames = [] screennames = self.getSkinPartsScreennames( config.plugins.MyMetrix.SkinPartPath.value + "screens/active/") metrixTools.callOnMainThread(self["output"].setText, _("Reading template file")) skindom = parse(config.plugins.MyMetrix.Templates.value) skinNode = skindom.getElementsByTagName('skin')[0] metrixTools.callOnMainThread(self["output"].setText, _("Setting colors")) self.setColor(skinNode) for screen in skinNode.getElementsByTagName('screen'): screenname = str(screen.getAttributeNode('name').nodeValue) metrixTools.callOnMainThread( self["output"].setText, (str(_("Checking screen ") + screenname))) if screenname in screennames: metrixTools.callOnMainThread( self["output"].setText, _(str("Removing default screen " + screenname))) parentNode = screen.parentNode parentNode.removeChild(screen) if config.plugins.MyMetrix.CleanInfoBar.value: if screenname in [ "InfoBar", "SecondInfoBar", "Nab_ExtraInfobar" ]: ib = skindom.createElement("screen") ib.setAttribute('backgroundColor', 'transparent') ib.setAttribute('flags', 'wfNoBorder') ib.setAttribute('name', screenname) ib.setAttribute('position', '0,0') ib.setAttribute('size', '1280,720') ib.setAttribute('title', "InfoBar") skinNode.appendChild(ib) print "############################ append " + screenname # APPEND STORE SCREENS path = config.plugins.MyMetrix.SkinPartPath.value + "screens/active/" dirs = listdir(path) for dir in dirs: metrixTools.callOnMainThread(self["output"].setText, _("Parsing SkinPart Screens")) try: screen = metrix_SkinPartTools.parseSkinPart( path + dir, "data.xml", "config.cfg", screenname) customscreen = skindom.importNode(screen, True) skinNode.appendChild(customscreen) except Exception, e: metrixTools.log("Error appending screen", e)
def threadworker(self): while(self.finished == False): if self.getCatalog == True: self.getCatalog = False menu = [] menu = menu + self.getSkinParts(config.plugins.MyMetrix.SkinPartPath.value + "widgets/active/","-on") menu = menu + self.getSkinParts(config.plugins.MyMetrix.SkinPartPath.value + "screens/active/","-on") menu = menu + self.getSkinParts(config.plugins.MyMetrix.SkinPartPath.value + "widgets/inactive/") menu = menu + self.getSkinParts(config.plugins.MyMetrix.SkinPartPath.value + "screens/inactive/") metrixTools.callOnMainThread(self.setList,menu) if self.getEntry == True: self.getEntry = False metrixTools.callOnMainThread(self.refreshMeta) time.sleep(1)
def getCategories(self): menu = [] menu.append(self.CategoryListEntry(_("Loading..."))) metrixTools.callOnMainThread(self.setList,menu) try: data = metrixCore.getWeb(self.url,True) dom = parseString(data) menu = [] ## ADD STATIC PSEUDO CATEGORIES menu.append(self.CategoryListEntry(_("Skins"), "Skins","skins")) menu.append(self.CategoryListEntry(_("MetrixColors"), "MetrixColors","brush")) menu.append(self.CategoryListEntry(_("Newest SkinParts"), "newest","new")) menu.append(self.CategoryListEntry(_("Last Modified"), "modified","recent")) menu.append(self.CategoryListEntry(_("Top 50 Downloads"), "mostdownloaded","download")) menu.append(self.CategoryListEntry(_("Skin Extensions"), "Extensions","extensions")) menu.append(self.CategoryListEntry(_("Bundles"), "bundle","bundle")) metrixTools.callOnMainThread(self.setList,menu) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) name = str(entry.getAttributeNode('name').nodeValue) menu.append(self.CategoryListEntry(name, item_id)) metrixTools.callOnMainThread(self.setList,menu) except Exception, e: metrixTools.log("Error getting items via web",e) menu.append(self.CategoryListEntry(_("Error loading data!"), "-","-")) metrixTools.callOnMainThread(self.setList,menu)
def threadworker(self): while(self.finished==False): if self.getCatalog == True: self.getCatalog = False self.getSkinParts() if self.getEntry == True: self.getEntry = False try: self.picPath = metrixTools.webPixmap(self["menu"].l.getCurrentSelection()[0][13] + "&width=550") except: pass metrixTools.callOnMainThread(self.refreshMeta) if self.action_downloadSkinPart == True: self.action_downloadSkinPart = False self.downloadSkinPart() time.sleep(1)
def threadworker(self): while(self.finished==False): if self.getCatalog == True: self.getCatalog = False self.getPackages() if self.getEntry == True: self.getEntry = False try: self.image = metrixTools.webPixmap(self["menu"].l.getCurrentSelection()[0][8],'openStoreImage',{'width':550}) except: pass metrixTools.callOnMainThread(self.refreshMeta) if self.action_downloadPackage == True: self.action_downloadPackage = False self.downloadPackage() time.sleep(1)
def threadworker(self): while (self.finished == False): if self.getCatalog == True: self.getCatalog = False self.getSkinParts() if self.getEntry == True: self.getEntry = False try: self.picPath = metrixTools.webPixmap( self["menu"].l.getCurrentSelection()[0][13] + "&width=550") except: pass metrixTools.callOnMainThread(self.refreshMeta) if self.action_downloadSkinPart == True: self.action_downloadSkinPart = False self.downloadSkinPart() time.sleep(1)
def getDesigns(self): menu = [] try: data = metrixCore.getWeb(metrixDefaults.URL_GET_METRIXCOLORS, True, {"name": self.currentname}) # print data dom = parseString(data) for design in dom.getElementsByTagName("design"): name = str(design.getAttributeNode("name").nodeValue) title = str(design.getAttributeNode("title").nodeValue) author = str(design.getAttributeNode("author").nodeValue) rating = str(design.getAttributeNode("rating").nodeValue) date = str(design.getAttributeNode("date").nodeValue) total_votes = str(design.getAttributeNode("total_votes").nodeValue) menu.append(self.DesignsListEntry(name, title, author, rating, date, total_votes)) metrixTools.callOnMainThread(self.setList, menu) except Exception, e: metrixTools.log("Error getting MetrixColor via web!", e) menu.append(self.DesignsListEntry("-", _("Error loading data!"))) metrixTools.callOnMainThread(self.setList, menu)
def daily(): while(1): metrixCore.setInfo() # Send general info to MetrixCloud try: if config.plugins.MyMetrix.AutoUpdateSkinParts.value: pass metrix_SkinPartTools.updateSkinParts() if config.plugins.MetrixUpdater.UpdateAvailable.value == 1: metrixTools.callOnMainThread(Notifications.AddNotification,metrix_UpdateAvailable.OpenScreen) except: traceback.print_exc() if config.plugins.MyMetrix.AutoUpdate.value: store_Updater.getUpdatedFiles() if config.plugins.MyMetrix.AutoUpdatePlugins.value: store_Updater.getUpdatedPackages() time.sleep(24*60*60)
def generateSkin(self): screennames = [] screennames = self.getSkinPartsScreennames(config.plugins.MyMetrix.SkinPartPath.value + "screens/active/") metrixTools.callOnMainThread(self["output"].setText,_("Reading template file")) skindom = parse(config.plugins.MyMetrix.Templates.value) skinNode = skindom.getElementsByTagName('skin')[0] metrixTools.callOnMainThread(self["output"].setText,_("Setting colors")) self.setColor(skinNode) for screen in skinNode.getElementsByTagName('screen'): screenname = str(screen.getAttributeNode('name').nodeValue) metrixTools.callOnMainThread(self["output"].setText,(str(_("Checking screen ")+screenname))) if screenname in screennames: metrixTools.callOnMainThread(self["output"].setText,_(str("Removing default screen "+screenname))) parentNode = screen.parentNode parentNode.removeChild(screen) if config.plugins.MyMetrix.CleanInfoBar.value: if screenname in ["InfoBar","SecondInfoBar","Nab_ExtraInfobar"]: ib = skindom.createElement("screen") ib.setAttribute('backgroundColor', 'transparent') ib.setAttribute('flags', 'wfNoBorder') ib.setAttribute('name', screenname) ib.setAttribute('position', '0,0') ib.setAttribute('size', '1280,720') ib.setAttribute('title', "InfoBar") skinNode.appendChild(ib) print "############################ append "+screenname # APPEND STORE SCREENS path = config.plugins.MyMetrix.SkinPartPath.value + "screens/active/" dirs = listdir(path) for dir in dirs: metrixTools.callOnMainThread(self["output"].setText,_("Parsing SkinPart Screens")) try: screen = metrix_SkinPartTools.parseSkinPart(path+dir,"data.xml","config.cfg",screenname) customscreen = skindom.importNode(screen, True) skinNode.appendChild(customscreen) except Exception, e: metrixTools.log("Error appending screen",e)
def threadworker(self): while (self.finished == False): if self.getCatalog == True: self.getCatalog = False menu = [] menu = menu + self.getSkinParts( config.plugins.MyMetrix.SkinPartPath.value + "widgets/active/", "-on") menu = menu + self.getSkinParts( config.plugins.MyMetrix.SkinPartPath.value + "screens/active/", "-on") menu = menu + self.getSkinParts( config.plugins.MyMetrix.SkinPartPath.value + "widgets/inactive/") menu = menu + self.getSkinParts( config.plugins.MyMetrix.SkinPartPath.value + "screens/inactive/") metrixTools.callOnMainThread(self.setList, menu) if self.getEntry == True: self.getEntry = False metrixTools.callOnMainThread(self.refreshMeta) time.sleep(1)
def getDesigns(self): menu = [] try: data = metrixCore.getWeb(metrixDefaults.URL_GET_METRIXCOLORS, True, {'name': self.currentname}) #print data dom = parseString(data) for design in dom.getElementsByTagName('design'): name = str(design.getAttributeNode('name').nodeValue) title = str(design.getAttributeNode('title').nodeValue) author = str(design.getAttributeNode('author').nodeValue) rating = str(design.getAttributeNode('rating').nodeValue) date = str(design.getAttributeNode('date').nodeValue) total_votes = str( design.getAttributeNode('total_votes').nodeValue) menu.append( self.DesignsListEntry(name, title, author, rating, date, total_votes)) metrixTools.callOnMainThread(self.setList, menu) except Exception, e: metrixTools.log("Error getting MetrixColor via web!", e) menu.append(self.DesignsListEntry("-", _("Error loading data!"))) metrixTools.callOnMainThread(self.setList, menu)
def __init__(self, session): self.session = session Screen.__init__(self, session) self["sort"] = Label() self.sort = "screens" self.url = metrixDefaults.URL_GET_SUITES self["menu"] = CategoryList([]) self.CategoryListEntry(_("Loading...")) self["actions"] = ActionMap( [ "OkCancelActions", "DirectionActions", "InputActions", "ColorActions" ], { "right": self.pageDown, "left": self.pageUp, "up": self.keyUp, "upRepeated": self.keyUp, "ok": self.go, "blue": self.changeSort, "down": self.keyDown, "downRepeated": self.keyDown, "cancel": self.exit }, -1) self.setTitle("OpenStore") self["title"] = Label(_("MyMetrix // OpenStore")) menu = [] menu.append(self.CategoryListEntry(_("Loading..."))) metrixTools.callOnMainThread(self.setList, menu) self["menu"].setList(menu) self.onLayoutFinish.append(self.changeSort)
def getCategories(self): menu = [] menu.append(self.CategoryListEntry(_("Loading..."))) metrixTools.callOnMainThread(self.setList, menu) try: data = metrixCore.getWeb(self.url, True) dom = parseString(data) menu = [] ## ADD STATIC PSEUDO CATEGORIES menu.append(self.CategoryListEntry(_("Skins"), "Skins", "skins")) menu.append( self.CategoryListEntry(_("MetrixColors"), "MetrixColors", "brush")) menu.append( self.CategoryListEntry(_("Newest SkinParts"), "newest", "new")) menu.append( self.CategoryListEntry(_("Last Modified"), "modified", "recent")) menu.append( self.CategoryListEntry(_("Top 50 Downloads"), "mostdownloaded", "download")) menu.append( self.CategoryListEntry(_("Skin Extensions"), "Extensions", "extensions")) menu.append( self.CategoryListEntry(_("Bundles"), "bundle", "bundle")) metrixTools.callOnMainThread(self.setList, menu) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) name = str(entry.getAttributeNode('name').nodeValue) menu.append(self.CategoryListEntry(name, item_id)) metrixTools.callOnMainThread(self.setList, menu) except Exception, e: metrixTools.log("Error getting items via web", e) menu.append( self.CategoryListEntry(_("Error loading data!"), "-", "-")) metrixTools.callOnMainThread(self.setList, menu)
def getSkinParts(self,isactive=""): menu = [] try: if self.pagelength == 0: params = {'screenname':self.screenname, 'suite_id':self.suite_id, 'developer':str(config.plugins.MyMetrix.Store.SkinPart_Developer.value), 'restrictions':metrixTools.getRestrictions(), 'orderby':self.orderby, 'type':str(self.type)} else: params = {'screenname':self.screenname, 'suite_id':self.suite_id, 'orderby':self.orderby, 'restrictions':metrixTools.getRestrictions(), 'developer':str(config.plugins.MyMetrix.Store.SkinPart_Developer.value), 'pagelength':str(self.pagelength), 'type':str(self.type), 'pagenum':'1'} data = metrixCore.getWeb(metrixDefaults.URL_GET_SKINPARTS,True,params) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) name = str(entry.getAttributeNode('name').nodeValue) author = str(entry.getAttributeNode('author').nodeValue) version = str(entry.getAttributeNode('version').nodeValue) rating = str(entry.getAttributeNode('rating').nodeValue) date = str(entry.getAttributeNode('date').nodeValue) item_type = str(entry.getAttributeNode('type').nodeValue) screenname = str(entry.getAttributeNode('screenname').nodeValue) image_id = str(entry.getAttributeNode('image_id').nodeValue) image_token = str(entry.getAttributeNode('image_token').nodeValue) total_votes = str(entry.getAttributeNode('total_votes').nodeValue) description = str(entry.getAttributeNode('description').nodeValue) build = str(entry.getAttributeNode('build').nodeValue) image_link = str(entry.getAttributeNode('image_link').nodeValue) downloads = str(entry.getAttributeNode('downloads').nodeValue) menu.append(self.SkinPartsListEntry(item_id,name,author,rating,date,version,total_votes,item_type,image_id,image_token,description,screenname,image_link,isactive,build)) metrixTools.callOnMainThread(self.setList,menu) if len(menu) < 1: self.picPath = metrixDefaults.PLUGIN_DIR + "images/sponsor.png" metrixTools.callOnMainThread(self.setList,menu) except Exception, e: metrixTools.log("Error getting SkinParts", e) self.picPath = metrixDefaults.PLUGIN_DIR + "images/sponsor.png" metrixTools.callOnMainThread (self.setList,menu)
def getPackages(self,isactive=""): menu = [] try: params = {'restrictions':metrixTools.getRestrictions(), 'orderby':self.orderby+" "+self.limit, 'category_id':str(self.category_id)} data = metrixCore.getWeb(self.url,True,params) if "<exception status=""error""" in data: raise Exception("Error loading data") dom = parseString(data) for design in dom.getElementsByTagName('entry'): isinstalled = False updateavailable = False item_id = str(design.getAttributeNode('id').nodeValue) name = str(design.getAttributeNode('name').nodeValue) author = str(design.getAttributeNode('author').nodeValue) version = str(design.getAttributeNode('version').nodeValue) rating = str(design.getAttributeNode('rating').nodeValue) date = str(design.getAttributeNode('date_created').nodeValue) date_modified = str(design.getAttributeNode('date_modified').nodeValue) item_type = str(design.getAttributeNode('type').nodeValue) file_link = str(design.getAttributeNode('file_link').nodeValue) image_link = str(design.getAttributeNode('image_link').nodeValue) icon_link = str(design.getAttributeNode('icon_link').nodeValue) downloads = str(design.getAttributeNode('downloads').nodeValue) total_votes = str(design.getAttributeNode('total_votes').nodeValue) build = int(design.getAttributeNode('build').nodeValue) description = str(design.getAttributeNode('description').nodeValue) previouspackage = str(design.getAttributeNode('previouspackage').nodeValue) path = metrixDefaults.pathRoot()+"packages/"+item_id localbuild = int(metrixDefaults.cfg(metrixDefaults.CONFIG_INSTALLEDPACKAGES,item_id,"build","int")) # add when not only updates or (only updates and online build is higher) if not localbuild == metrixDefaults.NONEINT: isinstalled = True if build > localbuild: updateavailable = True if (not self.onlyupdates and not self.onlyinstalled == True) or (build > localbuild and self.onlyupdates == True) or (self.onlyinstalled and isinstalled == True): menu.append(self.PackagesListEntry(item_id,name,author,rating,date,version,total_votes,item_type,image_link,icon_link,description,file_link,downloads,previouspackage,date_modified,build,isinstalled,updateavailable)) metrixTools.callOnMainThread(self.setList,menu) if len(menu) < 1: self.image = metrixDefaults.PLUGIN_DIR + "images/sponsor.png" metrixTools.callOnMainThread(self.setList,menu) except Exception, e: metrixTools.log('Error getting packages via web',e) self.image = metrixDefaults.PLUGIN_DIR + "images/sponsor.png" metrixTools.callOnMainThread(self.setList,menu)
def getPackages(self): menu = [] try: params = {'restriction-oe':metrixTools.getOERestriction(), 'restriction-image':metrixTools.getImageRestriction(), 'orderby':self.orderby+" "+self.limit, 'category_id':str(self.category_id)} data = metrixCore.getWeb(self.url,True,params) if "<exception status=""error""" in data: raise Exception("Error loading data") dom = parseString(data) for design in dom.getElementsByTagName('entry'): isinstalled = False updateavailable = False item_id = str(design.getAttributeNode('id').nodeValue) name = str(design.getAttributeNode('name').nodeValue) author = str(design.getAttributeNode('author').nodeValue) version = str(design.getAttributeNode('version').nodeValue) rating = str(design.getAttributeNode('rating').nodeValue) date = str(design.getAttributeNode('date_created').nodeValue) date_modified = str(design.getAttributeNode('date_modified').nodeValue) item_type = str(design.getAttributeNode('type').nodeValue) file_link = str(design.getAttributeNode('file_link').nodeValue) image_link = str(design.getAttributeNode('image_link').nodeValue) icon_link = str(design.getAttributeNode('icon_link').nodeValue) downloads = str(design.getAttributeNode('downloads').nodeValue) total_votes = str(design.getAttributeNode('total_votes').nodeValue) build = int(design.getAttributeNode('build').nodeValue) description = str(design.getAttributeNode('description').nodeValue) previouspackage = str(design.getAttributeNode('previouspackage').nodeValue) localbuild = int(metrixDefaults.cfg(metrixDefaults.CONFIG_INSTALLEDPACKAGES,item_id,"build","int")) # add when not only updates or (only updates and online build is higher) if (not localbuild == metrixDefaults.NONEINT) or item_id == config.plugins.MyMetrix.XPiconsRepository.value: isinstalled = True if build > localbuild: updateavailable = True if (not self.onlyupdates and not self.onlyinstalled == True) or (build > localbuild and self.onlyupdates == True) or (self.onlyinstalled and isinstalled == True): menu.append(self.PackagesListEntry(item_id,name,author,rating,date,version,total_votes,item_type,image_link,icon_link,description,file_link,downloads,previouspackage,date_modified,build,isinstalled,updateavailable)) metrixTools.callOnMainThread(self.setList,menu) if len(menu) < 1: self.image = metrixDefaults.PLUGIN_DIR + "images/sponsor.png" metrixTools.callOnMainThread(self.setList,menu) except Exception, e: metrixTools.log('Error getting packages via web',e) self.image = metrixDefaults.PLUGIN_DIR + "images/sponsor.png" metrixTools.callOnMainThread(self.setList,menu)
def downloadSkinPart(self): metrixTools.callOnMainThread(self["isInstalled"].setText,"Installing...") try: id = self.currentid type = self.currenttype author = self.currentauthor type = str(self["menu"].l.getCurrentSelection()[0][7]) image_link = str(self["menu"].l.getCurrentSelection()[0][13]) if type == "bundle": metrix_SkinPartTools.installBundle(id) else: metrix_SkinPartTools.installSkinPart(id,type,author,image_link) getCatalog = True getEntry = True metrixTools.callOnMainThread(self["isInstalled"].setText,"Installation successful!") except Exception, e: metrixTools.log("Error installing SkinPart "+id,e) metrixTools.callOnMainThread(self["isInstalled"].setText,"Error during installation!")
def downloadSkinPart(self): metrixTools.callOnMainThread(self["isInstalled"].setText, "Installing...") try: id = self.currentid type = self.currenttype author = self.currentauthor type = str(self["menu"].l.getCurrentSelection()[0][7]) image_link = str(self["menu"].l.getCurrentSelection()[0][13]) if type == "bundle": metrix_SkinPartTools.installBundle(id) else: metrix_SkinPartTools.installSkinPart(id, type, author, image_link) getCatalog = True getEntry = True metrixTools.callOnMainThread(self["isInstalled"].setText, "Installation successful!") except Exception, e: metrixTools.log("Error installing SkinPart " + id, e) metrixTools.callOnMainThread(self["isInstalled"].setText, "Error during installation!")
def getCategories(self): list = [[], [], [], [], []] selectionEnabled = False i = 1 list[i].append( self.CategoryEntry( i, "%", _("Installed"), "/img/categories/installed.png", onlyinstalled=True, orderby="date_modified desc", )) metrixTools.callOnMainThread(self.setList, list[i], i) i += 1 list[i].append( self.CategoryEntry( i, "%", _("Updates"), "/img/categories/updates.png", onlyupdates=True, orderby="date_modified desc", )) metrixTools.callOnMainThread(self.setList, list[i], i) i += 1 list[i].append( self.CategoryEntry(i, "%", _("New"), "/img/categories/new.png", orderby="date_created desc", limit="LIMIT 20")) metrixTools.callOnMainThread(self.setList, list[i], i) i += 1 list[i].append( self.CategoryEntry(i, "%", _("Last Modified"), "/img/categories/recent.png", orderby="date_modified desc", limit="LIMIT 20")) metrixTools.callOnMainThread(self.setList, list[i], i) i = 1 list[i].append( self.CategoryEntry(i, "%%", _("Top 50 Downloads"), "/img/categories/top50.png", orderby="rating desc", limit="LIMIT 50")) metrixTools.callOnMainThread(self.setList, list[i], i) i += 1 if config.plugins.MyMetrix.Store.Plugin_Developer.value: list[i].append( self.CategoryEntry( i, 9999, _("My Packages"), "/img/categories/my.png", orderby="date_modified desc", )) metrixTools.callOnMainThread(self.setList, list[i], i) i += 1 try: data = metrixCore.getWeb(metrixDefaults.URL_GET_CATEGORIES, True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) name = str(entry.getAttributeNode('name').nodeValue) image_link = str(entry.getAttributeNode('image').nodeValue) list[i].append( self.CategoryEntry(i, item_id, name, image_link, orderby="date_created desc")) metrixTools.callOnMainThread(self.setList, list[i], i) i += 1 if i == self.columns + 1: i = 1 metrixTools.callOnMainThread(self.setMaxRows, len(list[1]) + 1) except Exception, e: self.showInfo("Check your internet connection") metrixTools.log("Error getting categories via web!", e)
def setColor(self,skinNode): ###########READING DATA FILES try: if config.plugins.MyMetrix.Color.Selection.value == "CUSTOM": _selection = getHexColor(config.plugins.MyMetrix.Color.Selection_Custom.value,config.plugins.MyMetrix.Color.SelectionTransparency.value) else: _selection = config.plugins.MyMetrix.Color.Selection.value.replace("#00","#"+str(hex(int(config.plugins.MyMetrix.Color.SelectionTransparency.value)))) if config.plugins.MyMetrix.Color.Background2.value == "CUSTOM": _background2 = getHexColor(config.plugins.MyMetrix.Color.Background2_Custom.value,config.plugins.MyMetrix.Color.BackgroundTransparency.value) else: _background2 = config.plugins.MyMetrix.Color.Background2.value.replace("#00","#"+getHex(config.plugins.MyMetrix.Color.BackgroundTransparency.value)) if config.plugins.MyMetrix.Color.Background.value == "CUSTOM": _background = getHexColor(config.plugins.MyMetrix.Color.Background_Custom.value,config.plugins.MyMetrix.Color.BackgroundTransparency.value) else: _background = config.plugins.MyMetrix.Color.Background.value.replace("#00","#"+getHex(config.plugins.MyMetrix.Color.BackgroundTransparency.value)) if config.plugins.MyMetrix.Color.BackgroundText.value == "CUSTOM": _BackgroundText = getHexColor(config.plugins.MyMetrix.Color.BackgroundText_Custom.value, config.plugins.MyMetrix.Color.BackgroundTextTransparency.value) else: _BackgroundText = config.plugins.MyMetrix.Color.BackgroundText.value.replace("#00","#"+getHex(config.plugins.MyMetrix.Color.BackgroundTextTransparency.value)) if config.plugins.MyMetrix.Color.Foreground.value == "CUSTOM": _Foreground = getHexColor(config.plugins.MyMetrix.Color.Foreground_Custom.value) else: _Foreground = config.plugins.MyMetrix.Color.Foreground.value if config.plugins.MyMetrix.Color.Accent1.value == "CUSTOM": _Accent1 = getHexColor(config.plugins.MyMetrix.Color.Accent1_Custom.value) else: _Accent1 = config.plugins.MyMetrix.Color.Accent1.value if config.plugins.MyMetrix.Color.Accent2.value == "CUSTOM": _Accent2 = getHexColor(config.plugins.MyMetrix.Color.Accent2_Custom.value) else: _Accent2 = config.plugins.MyMetrix.Color.Accent2.value if config.plugins.MyMetrix.Color.Background.value == "CUSTOM": _transparent = getHexColor(config.plugins.MyMetrix.Color.Background_Custom.value,255) else: _transparent = config.plugins.MyMetrix.Color.Background.value.replace("#00","#ff") if config.plugins.MyMetrix.Color.BackgroundMode.value != "Dynamic": _transparent = config.plugins.MyMetrix.Color.BackgroundMode.value.replace("#00","#ff") colors = skinNode.getElementsByTagName('colors')[0] for color in colors.getElementsByTagName('color'): colorname = color.getAttributeNode('name').nodeValue metrixTools.callOnMainThread(self["output"].setText,_(str("Setting color: " + colorname))) if colorname == "metrixSelection": color.setAttribute('value',_selection) elif colorname == "metrixBackground": color.setAttribute('value',_background) elif colorname == "metrixBackground2": color.setAttribute('value',_background2) elif colorname == "metrixPreTrans": color.setAttribute('value',_BackgroundText) elif colorname == "metrixPreTrans2": color.setAttribute('value',_BackgroundText) elif colorname == "metrixForeground": color.setAttribute('value',_Foreground) elif colorname == "metrixAccent1": color.setAttribute('value',_Accent1) elif colorname == "metrixAccent2": color.setAttribute('value',_Accent2) elif colorname == "transparent": color.setAttribute('value',_transparent) except Exception, e: metrixTools.callOnMainThread(self["output"].setText,_(str("Error setting colors!"))) metrixTools.log("Error setting colors",e)
def updatestatus(self,message): metrixTools.callOnMainThread(self["isInstalled"].setText,message)
for screen in skinNode.getElementsByTagName('screen'): screenname = str(screen.getAttributeNode('name').nodeValue) if screenname == widgetscreenname and metrix_SkinPartTools.widgetActive(path+dir,"data.xml","config.cfg",screenname): for child in widget.childNodes: #raw_xml = raw_xml.replace("%SCREENNAME%",screenname) childimport = skindom.importNode(child, True) screen.appendChild(childimport) break except Exception, e: metrixTools.log("Error appending widget",e) for screen in skindom.getElementsByTagName('screen'): screenname = str(screen.getAttributeNode('name').nodeValue) metrixTools.callOnMainThread(self["output"].setText,_(str("Setting ProgressBars for "+screenname+" screen"))) try: for widget in screen.getElementsByTagName('widget'): try: pixmap = widget.getAttributeNode('pixmap').nodeValue if pixmap == metrixDefaults.getTemplateFiles() + "/colors/00ffffff.png": widget.setAttribute("pixmap",pixmap.replace("/00ffffff", "/" + config.plugins.MyMetrix.Color.ProgressBar.value.replace("#",""))) elif pixmap == "%METRIX:PROGRESSBAR:COLOR:MULTI%": widget.setAttribute("pixmap",metrixDefaults.getTemplateFiles() + "/colors/" + config.plugins.MyMetrix.Color.ProgressBar.value.replace("#","")+".png") elif pixmap == "%METRIX:PROGRESSBAR:COLOR:WHITE%": widget.setAttribute("pixmap",metrixDefaults.getTemplateFiles() + "/colors/00ffffff.png") except: pass except: pass
def openRating(self): metrixTools.callOnMainThread( self.session.open, store_SubmitRating.OpenScreen, self.currentid, self.currentgroup )
def showInfo(text,msg_type=MessageBox.TYPE_INFO): try: metrixTools.callOnMainThread(Notifications.AddNotification,MessageBox, _(text), type=msg_type,timeout=3) except Exception, e: metrixTools.log("Error",e)
def generateSkin(actionId): metrixTools.callOnMainThread(Notifications.AddNotification,metrix_GenerateSkin.OpenScreen, 3)
def getSkinParts(self, isactive=""): menu = [] try: if self.pagelength == 0: params = { 'screenname': self.screenname, 'suite_id': self.suite_id, 'developer': str(config.plugins.MyMetrix.Store.SkinPart_Developer.value ), 'restrictions': metrixTools.getRestrictions(), 'orderby': self.orderby, 'type': str(self.type) } else: params = { 'screenname': self.screenname, 'suite_id': self.suite_id, 'orderby': self.orderby, 'restrictions': metrixTools.getRestrictions(), 'developer': str(config.plugins.MyMetrix.Store.SkinPart_Developer.value ), 'pagelength': str(self.pagelength), 'type': str(self.type), 'pagenum': '1' } data = metrixCore.getWeb(metrixDefaults.URL_GET_SKINPARTS, True, params) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) name = str(entry.getAttributeNode('name').nodeValue) author = str(entry.getAttributeNode('author').nodeValue) version = str(entry.getAttributeNode('version').nodeValue) rating = str(entry.getAttributeNode('rating').nodeValue) date = str(entry.getAttributeNode('date').nodeValue) item_type = str(entry.getAttributeNode('type').nodeValue) screenname = str( entry.getAttributeNode('screenname').nodeValue) image_id = str(entry.getAttributeNode('image_id').nodeValue) image_token = str( entry.getAttributeNode('image_token').nodeValue) total_votes = str( entry.getAttributeNode('total_votes').nodeValue) description = str( entry.getAttributeNode('description').nodeValue) build = str(entry.getAttributeNode('build').nodeValue) image_link = str( entry.getAttributeNode('image_link').nodeValue) downloads = str(entry.getAttributeNode('downloads').nodeValue) menu.append( self.SkinPartsListEntry(item_id, name, author, rating, date, version, total_votes, item_type, image_id, image_token, description, screenname, image_link, isactive, build)) metrixTools.callOnMainThread(self.setList, menu) if len(menu) < 1: self.picPath = metrixDefaults.PLUGIN_DIR + "images/sponsor.png" metrixTools.callOnMainThread(self.setList, menu) except Exception, e: metrixTools.log("Error getting SkinParts", e) self.picPath = metrixDefaults.PLUGIN_DIR + "images/sponsor.png" metrixTools.callOnMainThread(self.setList, menu)
def showInfo(self, text=_("Information")): metrixTools.callOnMainThread(self.session.open, MessageBox, _(text), MessageBox.TYPE_INFO)
def openRating(self): metrixTools.callOnMainThread(self.session.open, store_SubmitRating.OpenScreen, self.currentid, self.currentgroup)
def getCategories(self): list = [[],[],[],[],[]] selectionEnabled = False i = 1 list[i].append(self.CategoryEntry(i,"%", _("Installed"), "/img/categories/installed.png",onlyinstalled=True,orderby="date_modified desc",)) metrixTools.callOnMainThread(self.setList,list[i],i) i += 1 list[i].append(self.CategoryEntry(i,"%", _("Updates"), "/img/categories/updates.png",onlyupdates=True,orderby="date_modified desc",)) metrixTools.callOnMainThread(self.setList,list[i],i) i += 1 list[i].append(self.CategoryEntry(i,"%", _("New"), "/img/categories/new.png",orderby="date_created desc", limit="LIMIT 20")) metrixTools.callOnMainThread(self.setList,list[i],i) i += 1 list[i].append(self.CategoryEntry(i,"%", _("Last Modified"), "/img/categories/recent.png",orderby="date_modified desc", limit="LIMIT 20")) metrixTools.callOnMainThread(self.setList,list[i],i) i = 1 list[i].append(self.CategoryEntry(i,"%%", _("Top 50 Downloads"), "/img/categories/top50.png",orderby="rating desc", limit="LIMIT 50")) metrixTools.callOnMainThread(self.setList,list[i],i) i += 1 if config.plugins.MyMetrix.Store.Plugin_Developer.value: list[i].append(self.CategoryEntry(i,9999, _("My Packages"), "/img/categories/my.png",orderby="date_modified desc",)) metrixTools.callOnMainThread(self.setList,list[i],i) i += 1 try: data = metrixCore.getWeb(metrixDefaults.URL_GET_CATEGORIES,True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) name = str(entry.getAttributeNode('name').nodeValue) image_link = str(entry.getAttributeNode('image').nodeValue) list[i].append(self.CategoryEntry(i,item_id, name, image_link,orderby="date_created desc")) metrixTools.callOnMainThread(self.setList,list[i],i) i += 1 if i == self.columns+1: i = 1 metrixTools.callOnMainThread(self.setMaxRows,len(list[1])+1) except Exception,e: showInfo("Check your internet connection") metrixTools.log("Error getting categories via web!",e)
class OpenScreen(ConfigListScreen, Screen): skin = """ <screen name="MyMetrix-GenerateSkin" position="-1,657" size="1285,64" flags="wfNoBorder" backgroundColor="#40000000"> <eLabel font="Regular; 20" foregroundColor="#00ffffff" backgroundColor="#40000000" halign="left" position="1115,16" size="163,33" text="Cancel" transparent="1" /> <eLabel position="20,7" size="190,50" text="MyMetrix" font="Regular; 40" valign="center" transparent="1" backgroundColor="#40000000" noWrap="1" /> <eLabel position="215,7" size="261,50" text="%s" foregroundColor="#00ffffff" font="Regular; 25" valign="center" backgroundColor="#40000000" transparent="1" halign="left" noWrap="1" /> <eLabel position="1103,13" size="5,50" backgroundColor="#00ff0000" /> <widget name="output" position="488,10" size="601,43" foregroundColor="#00ffffff" font="Regular; 22" valign="center" backgroundColor="#40000000" transparent="1" halign="left" noWrap="1" /> </screen> """ % (_("Generating Skin")) def __init__(self, session, args=None, picPath=None): Screen.__init__(self, session) self.session = session self["output"] = Label(_("Generating...")) self.generate = True self["actions"] = ActionMap([ "OkCancelActions", "DirectionActions", "InputActions", "ColorActions" ], { "cancel": self.exit, "red": self.exit }, -1) self.onLayoutFinish.append(self.startThread) def startThread(self): global thread_getDesigns thread_getDesigns = threading.Thread(target=self.threadworker, args=()) thread_getDesigns.daemon = True thread_getDesigns.start() #THREAD WORKER def threadworker(self): while (1): if self.generate == True: self.generate = False self.generateSkin() break time.sleep(1) def getSkinPartsScreennames(self, path): screennames = [] dirs = listdir(path) for dir in dirs: try: dom = parse(path + "/" + dir + "/data.xml") screen = dom.getElementsByTagName('screen')[0] name = str(screen.getAttributeNode('name').nodeValue) screennames.append(name) except: pass if config.plugins.MyMetrix.CleanInfoBar.value: screennames.append("InfoBar") screennames.append("SecondInfoBar") screennames.append("Nab_ExtraInfobar") return screennames def generateSkin(self): screennames = [] screennames = self.getSkinPartsScreennames( config.plugins.MyMetrix.SkinPartPath.value + "screens/active/") metrixTools.callOnMainThread(self["output"].setText, _("Reading template file")) skindom = parse(config.plugins.MyMetrix.Templates.value) skinNode = skindom.getElementsByTagName('skin')[0] metrixTools.callOnMainThread(self["output"].setText, _("Setting colors")) self.setColor(skinNode) for screen in skinNode.getElementsByTagName('screen'): screenname = str(screen.getAttributeNode('name').nodeValue) metrixTools.callOnMainThread( self["output"].setText, (str(_("Checking screen ") + screenname))) if screenname in screennames: metrixTools.callOnMainThread( self["output"].setText, _(str("Removing default screen " + screenname))) parentNode = screen.parentNode parentNode.removeChild(screen) if config.plugins.MyMetrix.CleanInfoBar.value: if screenname in [ "InfoBar", "SecondInfoBar", "Nab_ExtraInfobar" ]: ib = skindom.createElement("screen") ib.setAttribute('backgroundColor', 'transparent') ib.setAttribute('flags', 'wfNoBorder') ib.setAttribute('name', screenname) ib.setAttribute('position', '0,0') ib.setAttribute('size', '1280,720') ib.setAttribute('title', "InfoBar") skinNode.appendChild(ib) print "############################ append " + screenname # APPEND STORE SCREENS path = config.plugins.MyMetrix.SkinPartPath.value + "screens/active/" dirs = listdir(path) for dir in dirs: metrixTools.callOnMainThread(self["output"].setText, _("Parsing SkinPart Screens")) try: screen = metrix_SkinPartTools.parseSkinPart( path + dir, "data.xml", "config.cfg", screenname) customscreen = skindom.importNode(screen, True) skinNode.appendChild(customscreen) except Exception, e: metrixTools.log("Error appending screen", e) # APPEND STORE WIDGETS path = config.plugins.MyMetrix.SkinPartPath.value + "widgets/active/" dirs = listdir(path) for dir in dirs: try: widget = metrix_SkinPartTools.parseSkinPart( path + dir, "data.xml", "config.cfg", screenname, False) for widgetscreenname in str( widget.getAttributeNode('screenname').nodeValue).split( ","): metrixTools.callOnMainThread( self["output"].setText, str( _("Parsing SkinPart widget for ") + widgetscreenname)) for screen in skinNode.getElementsByTagName('screen'): screenname = str( screen.getAttributeNode('name').nodeValue) if screenname == widgetscreenname and metrix_SkinPartTools.widgetActive( path + dir, "data.xml", "config.cfg", screenname): for child in widget.childNodes: #raw_xml = raw_xml.replace("%SCREENNAME%",screenname) childimport = skindom.importNode(child, True) screen.appendChild(childimport) break except Exception, e: metrixTools.log("Error appending widget", e)
if screenname == widgetscreenname and metrix_SkinPartTools.widgetActive( path + dir, "data.xml", "config.cfg", screenname): for child in widget.childNodes: #raw_xml = raw_xml.replace("%SCREENNAME%",screenname) childimport = skindom.importNode(child, True) screen.appendChild(childimport) break except Exception, e: metrixTools.log("Error appending widget", e) for screen in skindom.getElementsByTagName('screen'): screenname = str(screen.getAttributeNode('name').nodeValue) metrixTools.callOnMainThread( self["output"].setText, _(str("Setting ProgressBars for " + screenname + " screen"))) try: for widget in screen.getElementsByTagName('widget'): try: pixmap = widget.getAttributeNode('pixmap').nodeValue if pixmap == metrixDefaults.getTemplateFiles( ) + "/colors/00ffffff.png": widget.setAttribute( "pixmap", pixmap.replace( "/00ffffff", "/" + config.plugins.MyMetrix. Color.ProgressBar.value.replace("#", ""))) elif pixmap == "%METRIX:PROGRESSBAR:COLOR:MULTI%": widget.setAttribute( "pixmap",
def rebootGui(actionId): metrixTools.log("Restarting GUI via web") showInfo(_("Restarting GUI!")) metrixTools.callOnMainThread(Notifications.AddNotification,TryQuitMainloop, 3)
def setColor(self, skinNode): ###########READING DATA FILES try: if config.plugins.MyMetrix.Color.Selection.value == "CUSTOM": _selection = getHexColor( config.plugins.MyMetrix.Color.Selection_Custom.value, config.plugins.MyMetrix.Color.SelectionTransparency.value) else: _selection = config.plugins.MyMetrix.Color.Selection.value.replace( "#00", "#" + str( hex( int(config.plugins.MyMetrix.Color. SelectionTransparency.value)))) if config.plugins.MyMetrix.Color.Background2.value == "CUSTOM": _background2 = getHexColor( config.plugins.MyMetrix.Color.Background2_Custom.value, config.plugins.MyMetrix.Color.BackgroundTransparency.value) else: _background2 = config.plugins.MyMetrix.Color.Background2.value.replace( "#00", "#" + getHex(config.plugins.MyMetrix.Color. BackgroundTransparency.value)) if config.plugins.MyMetrix.Color.Background.value == "CUSTOM": _background = getHexColor( config.plugins.MyMetrix.Color.Background_Custom.value, config.plugins.MyMetrix.Color.BackgroundTransparency.value) else: _background = config.plugins.MyMetrix.Color.Background.value.replace( "#00", "#" + getHex(config.plugins.MyMetrix.Color. BackgroundTransparency.value)) if config.plugins.MyMetrix.Color.BackgroundText.value == "CUSTOM": _BackgroundText = getHexColor( config.plugins.MyMetrix.Color.BackgroundText_Custom.value, config.plugins.MyMetrix.Color.BackgroundTextTransparency. value) else: _BackgroundText = config.plugins.MyMetrix.Color.BackgroundText.value.replace( "#00", "#" + getHex(config.plugins.MyMetrix.Color. BackgroundTextTransparency.value)) if config.plugins.MyMetrix.Color.Foreground.value == "CUSTOM": _Foreground = getHexColor( config.plugins.MyMetrix.Color.Foreground_Custom.value) else: _Foreground = config.plugins.MyMetrix.Color.Foreground.value if config.plugins.MyMetrix.Color.Accent1.value == "CUSTOM": _Accent1 = getHexColor( config.plugins.MyMetrix.Color.Accent1_Custom.value) else: _Accent1 = config.plugins.MyMetrix.Color.Accent1.value if config.plugins.MyMetrix.Color.Accent2.value == "CUSTOM": _Accent2 = getHexColor( config.plugins.MyMetrix.Color.Accent2_Custom.value) else: _Accent2 = config.plugins.MyMetrix.Color.Accent2.value if config.plugins.MyMetrix.Color.Background.value == "CUSTOM": _transparent = getHexColor( config.plugins.MyMetrix.Color.Background_Custom.value, 255) else: _transparent = config.plugins.MyMetrix.Color.Background.value.replace( "#00", "#ff") if config.plugins.MyMetrix.Color.BackgroundMode.value != "Dynamic": _transparent = config.plugins.MyMetrix.Color.BackgroundMode.value.replace( "#00", "#ff") colors = skinNode.getElementsByTagName('colors')[0] for color in colors.getElementsByTagName('color'): colorname = color.getAttributeNode('name').nodeValue metrixTools.callOnMainThread( self["output"].setText, _(str("Setting color: " + colorname))) if colorname == "metrixSelection": color.setAttribute('value', _selection) elif colorname == "metrixBackground": color.setAttribute('value', _background) elif colorname == "metrixBackground2": color.setAttribute('value', _background2) elif colorname == "metrixPreTrans": color.setAttribute('value', _BackgroundText) elif colorname == "metrixPreTrans2": color.setAttribute('value', _BackgroundText) elif colorname == "metrixForeground": color.setAttribute('value', _Foreground) elif colorname == "metrixAccent1": color.setAttribute('value', _Accent1) elif colorname == "metrixAccent2": color.setAttribute('value', _Accent2) elif colorname == "transparent": color.setAttribute('value', _transparent) except Exception, e: metrixTools.callOnMainThread(self["output"].setText, _(str("Error setting colors!"))) metrixTools.log("Error setting colors", e)