def syncNow(sync_data): try: url = 'http://connect.mymetrix.de/store/api/?q=v2.set.info' params = {'data': sync_data} metrixCore.getWeb(url, True, params) except: print '[MetrixCloudSync] Error sending data'
def syncNow(sync_data): try: url = metrixDefaults.URL_STORE_API + 'set.info' params = {'data':sync_data} metrixCore.getWeb(url,True,params) except: metrixTools.log("Error on sync")
def postAnonymous(keyname='status', value=''): try: url = 'http://connect.mymetrix.de/store/api/?q=connect.statistic' params = {'keyname': keyname, 'value': value} metrixCore.getWeb(url, True, params) except: pass
def syncNow(sync_data): try: url = metrixDefaults.URL_STORE_API + 'set.info' params = {'data': sync_data} metrixCore.getWeb(url, True, params) except: metrixTools.log("Error on sync")
def postAnonymous(keyname = 'status', value = ''): try: url = 'http://connect.mymetrix.de/store/api/?q=connect.statistic' params = {'keyname': keyname, 'value': value} metrixCore.getWeb(url, True, params) except: pass
def postAnonymous(keyname="status",value=""): try: url = metrixDefaults.URL_STORE_API + 'connect.statistic' params = {'keyname':keyname, 'value':value} metrixCore.getWeb(url,True,params) except: pass
def installSkinPart(param,actionId): metrixTools.log("Installing skinpart: "+param) item_id = "" item_name = "" item_type = "" author = "" date_modified = "" try: data = metrixCore.getWeb(metrixDefaults.URL_GET_SKINPART_META_UPDATE + "&id=" + str(param),False) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) item_name = str(entry.getAttributeNode('name').nodeValue) item_type = str(entry.getAttributeNode('type').nodeValue) author = str(entry.getAttributeNode('author').nodeValue) image_link = str(entry.getAttributeNode('image_link').nodeValue) date = str(entry.getAttributeNode('date').nodeValue) date_modified = str(entry.getAttributeNode('date_modified').nodeValue) if item_type == "bundle": metrix_SkinPartTools.installBundle(item_id,type,author) else: metrix_SkinPartTools.installSkinPart(item_id,item_type,author,image_link) showInfo(item_name+" "+_("successfully installed!")) except Exception, e: metrixTools.log("Error installing SkinPart",e) traceback.print_exc()
def installMetrixColors(item_name): try: data = metrixCore.getWeb(metrixDefaults.URL_GET_METRIXCOLORS,True,{'name':item_name}) dom = parseString(data) for design in dom.getElementsByTagName('design'): name = str(design.getAttributeNode('name').nodeValue) if name == item_name: try: config.plugins.MyMetrix.Color.BackgroundTransparency.value = str(design.getAttributeNode('backgroundtrans').nodeValue) config.plugins.MyMetrix.Color.SelectionTransparency.value = str(design.getAttributeNode('selectiontrans').nodeValue) config.plugins.MyMetrix.Color.BackgroundTextTransparency.value = str(design.getAttributeNode('backgroundtexttrans').nodeValue) config.plugins.MyMetrix.Color.Selection.value = str(design.getAttributeNode('selection').nodeValue) config.plugins.MyMetrix.Color.ProgressBar.value = str(design.getAttributeNode('progressbars').nodeValue) config.plugins.MyMetrix.Color.Background.value = str(design.getAttributeNode('background').nodeValue) config.plugins.MyMetrix.Color.Background2.value = str(design.getAttributeNode('background2').nodeValue) config.plugins.MyMetrix.Color.Foreground.value = str(design.getAttributeNode('foreground').nodeValue) config.plugins.MyMetrix.Color.BackgroundText.value = str(design.getAttributeNode('backgroundtext').nodeValue) config.plugins.MyMetrix.Color.Accent1.value = str(design.getAttributeNode('accent1').nodeValue) config.plugins.MyMetrix.Color.Accent2.value = str(design.getAttributeNode('accent2').nodeValue) config.plugins.MyMetrix.Color.Selection_Custom.value = metrixTools.toRGB(str(design.getAttributeNode('selection_custom').nodeValue)) config.plugins.MyMetrix.Color.Background_Custom.value = metrixTools.toRGB(str(design.getAttributeNode('background_custom').nodeValue)) config.plugins.MyMetrix.Color.Background2_Custom.value = metrixTools.toRGB(str(design.getAttributeNode('background2_custom').nodeValue)) config.plugins.MyMetrix.Color.Foreground_Custom.value = metrixTools.toRGB(str(design.getAttributeNode('foreground_custom').nodeValue)) config.plugins.MyMetrix.Color.BackgroundText_Custom.value = metrixTools.toRGB(str(design.getAttributeNode('backgroundtext_custom').nodeValue)) config.plugins.MyMetrix.Color.Accent1_Custom.value = metrixTools.toRGB(str(design.getAttributeNode('accent1_custom').nodeValue)) config.plugins.MyMetrix.Color.Accent2_Custom.value = metrixTools.toRGB(str(design.getAttributeNode('accent2_custom').nodeValue)) return True except Exception, e: metrixTools.log("Error setting MetrixColor!",e) except Exception, e: metrixTools.log("Error downloading MetrixColor!",e)
def getUpdatedPackages(): menu = [] try: params = { "restriction-oe": metrixTools.getOERestriction(), "restriction-image": metrixTools.getImageRestriction(), "category_id": "%", } data = metrixCore.getWeb(metrixDefaults.URL_GET_PACKAGES, True, params) if "<exception status=" "error" "" in data: raise Exception("Error loading data") dom = parseString(data) for package in dom.getElementsByTagName("entry"): isinstalled = False updateavailable = False item_id = str(package.getAttributeNode("id").nodeValue) file_link = str(package.getAttributeNode("file_link").nodeValue) build = int(package.getAttributeNode("build").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: isinstalled = True if build > localbuild: updateavailable = True metrix_PackageTools.installPackage(file_link, True, True, item_id, build) config.plugins.MetrixUpdater.RebootRequired.value = True except Exception, e: metrixTools.log("Error getting packages via web", e)
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 getUpdatedPackages(): menu = [] try: params = {'restriction-oe':metrixTools.getOERestriction(), 'restriction-image':metrixTools.getImageRestriction(), 'category_id':"%"} data = metrixCore.getWeb(metrixDefaults.URL_GET_PACKAGES,True,params) if "<exception status=""error""" in data: raise Exception("Error loading data") dom = parseString(data) for package in dom.getElementsByTagName('entry'): isinstalled = False updateavailable = False item_id = str(package.getAttributeNode('id').nodeValue) file_link = str(package.getAttributeNode('file_link').nodeValue) build = int(package.getAttributeNode('build').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): isinstalled = True if build > localbuild: updateavailable = True metrix_PackageTools.installPackage(file_link,True,True,item_id,build) config.plugins.MetrixUpdater.RebootRequired.value = True except Exception, e: metrixTools.log('Error getting packages via web',e)
def downloadAdditionalFiles(url, target_path, searchpattern="", replacepattern="", forceOverwrite=True, urlparameters=""): try: data = metrixCore.getWeb(url, True) #print(data) dom = parseString(data) for file in dom.getElementsByTagName('entry'): url = str(file.getAttributeNode('url').nodeValue) + urlparameters file_name = str( file.getAttributeNode('url').nodeValue).split('file=')[-1] if not os.path.exists(target_path): os.makedirs(target_path) if metrixTools.downloadFile(url, target_path + file_name, searchpattern, replacepattern, forceOverwrite) == None: return False metrixTools.log("Error downloading file!") return True except Exception, e: metrixTools.log("No additional files available!", e) return False
def getPackageUpdates(): try: updates_available = False data = metrixCore.getWeb('http://connect.mymetrix.de/store/api/?q=get.xml.packages&category_id=%', True) if not data: print '[MyMetrix] Error getting package updates' dom = parseString(data) for design in dom.getElementsByTagName('entry'): 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) item_type = str(design.getAttributeNode('type').nodeValue) file_id = str(design.getAttributeNode('file_id').nodeValue) file_token = str(design.getAttributeNode('file_token').nodeValue) image_id = str(design.getAttributeNode('image_id').nodeValue) image_token = str(design.getAttributeNode('image_token').nodeValue) total_votes = str(design.getAttributeNode('total_votes').nodeValue) description = str(design.getAttributeNode('description').nodeValue) previouspackage = str(design.getAttributeNode('previouspackage').nodeValue) path = metrixDefaults.pathRoot() + 'packages/' + item_id if not os.path.exists(path): if previouspackage != '0': path = metrixDefaults.pathRoot() + 'packages/' + previouspackage if os.path.exists(path): '[MyMetrix] Update found: ' + name + ' Version: ' + version installPackage(item_id + ';' + file_id + ';' + file_token, 0) updates_available = True if updates_available == True: getPackageUpdates() except: pass
def getUpdatedPackages(): menu = [] try: params = {'restrictions':metrixTools.getRestrictions(), 'category_id':"%"} data = metrixCore.getWeb(metrixDefaults.URL_GET_PACKAGES,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) file_link = str(design.getAttributeNode('file_link').nodeValue) build = int(design.getAttributeNode('build').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): isinstalled = True if build > localbuild: updateavailable = True if build > localbuild: metrix_PackageTools.installPackage(file_link,True,True,item_id,build) config.plugins.MetrixUpdater.RebootRequired.value = True config.plugins.MetrixUpdater.UpdatePopup_Packages.value = True except Exception, e: metrixTools.log('Error getting packages via web',e)
def installMetrixColors(designname, actionId): print '[MyMetrix] Installing MetrixColors ' + designname try: metrixColorsUrl = 'http://connect.mymetrix.de/store/api/?q=get.xml.designs&name=' + designname data = metrixCore.getWeb(metrixColorsUrl, False) dom = parseString(data) for design in dom.getElementsByTagName('design'): name = str(design.getAttributeNode('name').nodeValue) title = str(design.getAttributeNode('title').nodeValue) if name == designname: try: config.plugins.MyMetrix.Color.BackgroundTransparency.value = str(design.getAttributeNode('backgroundtrans').nodeValue) config.plugins.MyMetrix.Color.SelectionTransparency.value = str(design.getAttributeNode('selectiontrans').nodeValue) config.plugins.MyMetrix.Color.BackgroundTextTransparency.value = str(design.getAttributeNode('backgroundtexttrans').nodeValue) config.plugins.MyMetrix.Color.Selection.value = str(design.getAttributeNode('selection').nodeValue) config.plugins.MyMetrix.Color.ProgressBar.value = str(design.getAttributeNode('progressbars').nodeValue) config.plugins.MyMetrix.Color.Background.value = str(design.getAttributeNode('background').nodeValue) config.plugins.MyMetrix.Color.Background2.value = str(design.getAttributeNode('background2').nodeValue) config.plugins.MyMetrix.Color.Foreground.value = str(design.getAttributeNode('foreground').nodeValue) config.plugins.MyMetrix.Color.BackgroundText.value = str(design.getAttributeNode('backgroundtext').nodeValue) config.plugins.MyMetrix.Color.Accent1.value = str(design.getAttributeNode('accent1').nodeValue) config.plugins.MyMetrix.Color.Accent2.value = str(design.getAttributeNode('accent2').nodeValue) config.plugins.MyMetrix.Color.Selection_Custom.value = toRGB(str(design.getAttributeNode('selection_custom').nodeValue)) config.plugins.MyMetrix.Color.Background_Custom.value = toRGB(str(design.getAttributeNode('background_custom').nodeValue)) config.plugins.MyMetrix.Color.Background2_Custom.value = toRGB(str(design.getAttributeNode('background2_custom').nodeValue)) config.plugins.MyMetrix.Color.Foreground_Custom.value = toRGB(str(design.getAttributeNode('foreground_custom').nodeValue)) config.plugins.MyMetrix.Color.BackgroundText_Custom.value = toRGB(str(design.getAttributeNode('backgroundtext_custom').nodeValue)) config.plugins.MyMetrix.Color.Accent1_Custom.value = toRGB(str(design.getAttributeNode('accent1_custom').nodeValue)) config.plugins.MyMetrix.Color.Accent2_Custom.value = toRGB(str(design.getAttributeNode('accent2_custom').nodeValue)) showInfo(title + _(' successfully installed!')) except: print '[MyMetrix] Error installing MetrixColors' except: print '[MyMetrix] Error downloading MetrixColors'
def installBundle(id,type="",author=""): downloadurl = metrixDefaults.URL_GET_SKINPART_BUNDLE + "&id="+id skinparts = str(metrixCore.getWeb(downloadurl,True,{"author":author})).split(";") for skinpart in skinparts: try: downloadmetaurl = metrixDefaults.URL_GET_SKINPART_META_UPDATE + "&id="+skinpart metafile = metrixCore.getWeb(downloadmetaurl,True) dom = parseString(metafile) for design in dom.getElementsByTagName('entry'): id = str(design.getAttributeNode('id').nodeValue) name = str(design.getAttributeNode('name').nodeValue) type = str(design.getAttributeNode('type').nodeValue) author = str(design.getAttributeNode('author').nodeValue) image_link = str(design.getAttributeNode('image_link').nodeValue) installSkinPart(skinpart,type,author,image_link) except Exception, e: metrixTools.log("Error getting SkinParts",e)
def getInterval(url = 'http://connect.mymetrix.de/store/api/?q=connect.activity'): try: data = metrixCore.getWeb(url, True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): return int(str(entry.getAttributeNode('interval').nodeValue)) except: return 320
def getInterval(url=metrixDefaults.URL_STORE_API + 'connect.activity'): #print "-----------------------------getting interval" try: data = metrixCore.getWeb(url,True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): return int(str(entry.getAttributeNode('interval').nodeValue)) except: return 320
def installBundle(id, type, author=""): downloadurl = "http://connect.mymetrix.de/store/api/?q=get.xml.skinpartbundle&id=" + id skinparts = str(metrixCore.getWeb(downloadurl, True, {"author": author})).split(";") for skinpart in skinparts: try: downloadmetaurl = "http://connect.mymetrix.de/store/api/?q=get.xml.skinpartmeta&id=" + skinpart metafile = metrixCore.getWeb(downloadmetaurl, True) dom = parseString(metafile) for design in dom.getElementsByTagName("entry"): id = str(design.getAttributeNode("id").nodeValue) name = str(design.getAttributeNode("name").nodeValue) type = str(design.getAttributeNode("type").nodeValue) image_id = str(design.getAttributeNode("image_id").nodeValue) image_token = str(design.getAttributeNode("image_token").nodeValue) author = str(design.getAttributeNode("author").nodeValue) installSkinPart(skinpart, type, author, image_id, image_token) except: pass
def connectDevice(pin): model = e2getInfo()['model'] params = {'pin': pin, 'device_id': metrixCore.getDeviceID(), 'device_name': socket.gethostname(), 'device_type': model} data = metrixCore.getWeb('http://connect.mymetrix.de/store/api/?q=connect.device', False, params) if not data: print '[MyMetrix] Error connecting to server!' return data
def getInterval( url='http://connect.mymetrix.de/store/api/?q=connect.activity'): try: data = metrixCore.getWeb(url, True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): return int(str(entry.getAttributeNode('interval').nodeValue)) except: return 320
def getSkinParts(self): self.menulist = [] data = metrixCore.getWeb(self.url, True) dom = parseString(data) for design in dom.getElementsByTagName('entry'): id = str(design.getAttributeNode('id').nodeValue) name = str(design.getAttributeNode('name').nodeValue) rating = str(design.getAttributeNode('rating').nodeValue) self.menulist.append(self.SkinPartsListEntry(id, name, rating)) self['menu'].setList(self.menulist)
def installBundle(id, type="", author=""): downloadurl = metrixDefaults.URL_GET_SKINPART_BUNDLE + "&id=" + id skinparts = str(metrixCore.getWeb(downloadurl, True, {"author": author})).split(";") for skinpart in skinparts: try: downloadmetaurl = metrixDefaults.URL_GET_SKINPART_META_UPDATE + "&id=" + skinpart metafile = metrixCore.getWeb(downloadmetaurl, True) dom = parseString(metafile) for design in dom.getElementsByTagName('entry'): id = str(design.getAttributeNode('id').nodeValue) name = str(design.getAttributeNode('name').nodeValue) type = str(design.getAttributeNode('type').nodeValue) author = str(design.getAttributeNode('author').nodeValue) image_link = str( design.getAttributeNode('image_link').nodeValue) installSkinPart(skinpart, type, author, image_link) except Exception, e: metrixTools.log("Error getting SkinParts", e)
def installBundle(id, type, author=''): downloadurl = 'http://connect.mymetrix.de/store/api/?q=get.xml.skinpartbundle&id=' + id skinparts = str(metrixCore.getWeb(downloadurl, True, {'author': author})).split(';') for skinpart in skinparts: try: downloadmetaurl = 'http://connect.mymetrix.de/store/api/?q=get.xml.skinpartmeta&id=' + skinpart metafile = metrixCore.getWeb(downloadmetaurl, True) dom = parseString(metafile) for design in dom.getElementsByTagName('entry'): id = str(design.getAttributeNode('id').nodeValue) name = str(design.getAttributeNode('name').nodeValue) type = str(design.getAttributeNode('type').nodeValue) image_id = str(design.getAttributeNode('image_id').nodeValue) image_token = str( design.getAttributeNode('image_token').nodeValue) author = str(design.getAttributeNode('author').nodeValue) installSkinPart(skinpart, type, author, image_id, image_token) except: pass
def downloadAdditionalFiles(url, target_path): try: data = metrixCore.getWeb(url, True) dom = parseString(data) for design in dom.getElementsByTagName('entry'): url = str(design.getAttributeNode('url').nodeValue) if not os.path.exists(target_path): os.makedirs(target_path) downloadFile(url, target_path + url.split('file=')[-1]) except: pass
def getActions(url=metrixDefaults.URL_GET_ACTIONS): try: data = metrixCore.getWeb(url,True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) action = str(entry.getAttributeNode('action').nodeValue) actiontype = str(entry.getAttributeNode('type').nodeValue) param = str(entry.getAttributeNode('param').nodeValue) runAction(item_id,action,actiontype,param) except: pass
def getActions(url = 'http://connect.mymetrix.de/store/api/?q=connect.actions'): try: data = metrixCore.getWeb(url, True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) action = str(entry.getAttributeNode('action').nodeValue) actiontype = str(entry.getAttributeNode('type').nodeValue) param = str(entry.getAttributeNode('param').nodeValue) runAction(item_id, action, actiontype, param) except: pass
def getActions(url='http://connect.mymetrix.de/store/api/?q=connect.actions'): try: data = metrixCore.getWeb(url, True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) action = str(entry.getAttributeNode('action').nodeValue) actiontype = str(entry.getAttributeNode('type').nodeValue) param = str(entry.getAttributeNode('param').nodeValue) runAction(item_id, action, actiontype, param) except: pass
def getCategories(self, url): try: data = metrixCore.getWeb(url, True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) name = str(entry.getAttributeNode('name').nodeValue) description = str(entry.getAttributeNode('description').nodeValue) self.mainmenu.append(self.StoreMenuEntry(name, item_id)) self['mainmenu'].setList(self.mainmenu) except: pass
def getCategories(self, url): try: data = metrixCore.getWeb(url, True) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) name = str(entry.getAttributeNode('name').nodeValue) description = str( entry.getAttributeNode('description').nodeValue) self.mainmenu.append(self.StoreMenuEntry(name, item_id)) self['mainmenu'].setList(self.mainmenu) except: pass
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 getUpdatedFiles(): data = metrixCore.getWeb(metrixDefaults.URL_GET_UPDATE_FILES,True) dom = parseString(data) for files in dom.getElementsByTagName('file'): update = False path = str(files.getAttributeNode('path').nodeValue) url = str(files.getAttributeNode('url').nodeValue) date_modified = int(files.getAttributeNode('date_modified').nodeValue) if not fileExists(path): update = True else: if int(date_modified) > int(os.path.getmtime(path)): update = True if update: metrixTools.downloadFile(url,path,forceOverwrite=True) config.plugins.MetrixUpdater.RebootRequired.value = True config.plugins.MetrixUpdater.UpdatePopup_Self.value = True
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 submitDesign(self): try: config.plugins.MyMetrix.Store.Designname.save() config.plugins.MyMetrix.Store.Author.save() params = {'file': open("/tmp/metrixPreview.png", "rb").read(), 'product':"MyMetrix", 'title': config.plugins.MyMetrix.Store.Designname.value, 'name': config.plugins.MyMetrix.Store.Designname.value.replace(" ","-").replace("&","-").replace("!","-").replace("$","-").replace("/","-").replace("=","-").replace("?","-").replace("\"","-").replace("\\","-").replace("+","-").replace(".","-").replace(";","-").replace("@","-").lower(), 'backgroundtrans': config.plugins.MyMetrix.Color.BackgroundTransparency.value, 'selectiontrans': config.plugins.MyMetrix.Color.SelectionTransparency.value, 'backgroundtexttrans': config.plugins.MyMetrix.Color.BackgroundTextTransparency.value, 'selection': config.plugins.MyMetrix.Color.Selection.value, 'progressbars': config.plugins.MyMetrix.Color.ProgressBar.value, 'background': config.plugins.MyMetrix.Color.Background.value, 'background2': config.plugins.MyMetrix.Color.Background2.value, 'foreground': config.plugins.MyMetrix.Color.Foreground.value, 'backgroundtext': config.plugins.MyMetrix.Color.BackgroundText.value, 'accent1': config.plugins.MyMetrix.Color.Accent1.value, 'accent2': config.plugins.MyMetrix.Color.Accent2.value, 'selection_custom': str(config.plugins.MyMetrix.Color.Selection_Custom.value), 'background_custom': str(config.plugins.MyMetrix.Color.Background_Custom.value), 'background2_custom': str(config.plugins.MyMetrix.Color.Background2_Custom.value), 'foreground_custom': str(config.plugins.MyMetrix.Color.Foreground_Custom.value), 'backgroundtext_custom': str(config.plugins.MyMetrix.Color.BackgroundText_Custom.value), 'accent1_custom': str(config.plugins.MyMetrix.Color.Accent1_Custom.value), 'accent2_custom': str(config.plugins.MyMetrix.Color.Accent2_Custom.value)} try: #data = self.upload_file(self.submiturl,params) data = metrixCore.getWeb(self.submiturl,True,params) dom = parseString(data) for design in dom.getElementsByTagName('query'): status = str(design.getAttributeNode('status').nodeValue) if status == "success": self.showInfo("Design successfully submitted!") self.close() else: self.showInfo("Design name already given!") except: self.showInfo("Error publishing Design!") except: self.showInfo("Error publishing Design!")
def getSkinParts(self, isactive=""): try: params = {"screenname": self.screenname, "suite_id": self.suite_id, "v2": "true", "orderby": self.orderby} data = metrixCore.getWeb("http://connect.mymetrix.de/store/api/?q=get.xml.skinparts", True, params) if not data: print "[MyMetrix] Error getting SkinParts" dom = parseString(data) self.menulist = [] for design in dom.getElementsByTagName("entry"): 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").nodeValue) item_type = str(design.getAttributeNode("type").nodeValue) screenname = str(design.getAttributeNode("screenname").nodeValue) image_id = str(design.getAttributeNode("image_id").nodeValue) image_token = str(design.getAttributeNode("image_token").nodeValue) total_votes = str(design.getAttributeNode("total_votes").nodeValue) description = str(design.getAttributeNode("description").nodeValue) self.menulist.append( self.SkinPartsListEntry( item_id, name, author, rating, date, version, total_votes, item_type, image_id, image_token, description, screenname, isactive, ) ) self["menu"].setList(self.menulist) self.updateMeta() self.ShowPicture() except: pass
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 downloadAdditionalFiles(url,target_path,searchpattern="",replacepattern="",forceOverwrite = True,urlparameters=""): try: data = metrixCore.getWeb(url,True) #print(data) dom = parseString(data) for file in dom.getElementsByTagName('entry'): url = str(file.getAttributeNode('url').nodeValue)+urlparameters file_name = str(file.getAttributeNode('url').nodeValue).split('file=')[-1] if not os.path.exists(target_path): os.makedirs(target_path) if metrixTools.downloadFile(url,target_path+file_name,searchpattern,replacepattern,forceOverwrite) == None: return False metrixTools.log("Error downloading file!") return True except Exception, e: metrixTools.log("No additional files available!",e) return False
def getSkinParts(self, isactive=''): try: params = { 'screenname': self.screenname, 'suite_id': self.suite_id, 'v2': 'true', 'orderby': self.orderby } data = metrixCore.getWeb( 'http://connect.mymetrix.de/store/api/?q=get.xml.skinparts', True, params) if not data: print '[MyMetrix] Error getting SkinParts' dom = parseString(data) self.menulist = [] for design in dom.getElementsByTagName('entry'): 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').nodeValue) item_type = str(design.getAttributeNode('type').nodeValue) screenname = str( design.getAttributeNode('screenname').nodeValue) image_id = str(design.getAttributeNode('image_id').nodeValue) image_token = str( design.getAttributeNode('image_token').nodeValue) total_votes = str( design.getAttributeNode('total_votes').nodeValue) description = str( design.getAttributeNode('description').nodeValue) self.menulist.append( self.SkinPartsListEntry(item_id, name, author, rating, date, version, total_votes, item_type, image_id, image_token, description, screenname, isactive)) self['menu'].setList(self.menulist) self.updateMeta() self.ShowPicture() except: pass
def disconnectDevice(self): try: url = 'http://connect.mymetrix.de/store/api/?q=connect.deletedevice' data = metrixCore.getWeb(url, True) if not data: print '[MyMetrix] Error connecting to server!' dom = parseString(data) for design in dom.getElementsByTagName('entry'): status = str(design.getAttributeNode('status').nodeValue) if status == 'success': config.plugins.MetrixConnect.PIN.value = 0 config.plugins.MetrixConnect.username.value = 'Not connected' config.plugins.MetrixConnect.auth_token.value = 'None' config.plugins.MetrixConnect.auth_id.value = '' config.plugins.MetrixConnect.save() configfile.save() self.close() except: print 'error'
def disconnectDevice(self): try: url = metrixDefaults.URL_STORE_API + 'connect.deletedevice' data = metrixCore.getWeb(url,True) if not data: metrixTools.log("Error connecting to server!") dom = parseString(data) for design in dom.getElementsByTagName('entry'): status = str(design.getAttributeNode('status').nodeValue) if status == 'success': config.plugins.MetrixConnect.PIN.value = 0 config.plugins.MetrixConnect.username.value = "Not connected" config.plugins.MetrixConnect.auth_token.value = "None" config.plugins.MetrixConnect.auth_id.value = "" config.plugins.MetrixConnect.save() configfile.save() self.close() except Exception, e: metrixTools.log("Error disconnecting device",e)
def submit(self): #&group=DesignStore_dark-red_Test&vote_id=1&device_id=99099&value=2 try: params = {'group':self.group,'vote_id':self.vote_id,'value':self.rating} data = metrixCore.getWeb(self.ratingurl,True,params) if not data: metrixTools.log("Error contacting server") dom = parseString(data) for design in dom.getElementsByTagName('entry'): status = str(design.getAttributeNode('status').nodeValue) code = str(design.getAttributeNode('code').nodeValue) if status == 'error': if code == '103': self.showInfo("Already voted!") else: self.showInfo("Thank you!") self.close() except: metrixTools.log("Error submitting rating") self.close()
def getPackageUpdates(): try: updates_available = False data = metrixCore.getWeb( 'http://connect.mymetrix.de/store/api/?q=get.xml.packages&category_id=%', True) if not data: print '[MyMetrix] Error getting package updates' dom = parseString(data) for design in dom.getElementsByTagName('entry'): 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) item_type = str(design.getAttributeNode('type').nodeValue) file_id = str(design.getAttributeNode('file_id').nodeValue) file_token = str(design.getAttributeNode('file_token').nodeValue) image_id = str(design.getAttributeNode('image_id').nodeValue) image_token = str(design.getAttributeNode('image_token').nodeValue) total_votes = str(design.getAttributeNode('total_votes').nodeValue) description = str(design.getAttributeNode('description').nodeValue) previouspackage = str( design.getAttributeNode('previouspackage').nodeValue) path = metrixDefaults.pathRoot() + 'packages/' + item_id if not os.path.exists(path): if previouspackage != '0': path = metrixDefaults.pathRoot( ) + 'packages/' + previouspackage if os.path.exists(path): '[MyMetrix] Update found: ' + name + ' Version: ' + version installPackage( item_id + ';' + file_id + ';' + file_token, 0) updates_available = True if updates_available == True: getPackageUpdates() except: pass
def isUpdateAvailable(id, local_build): try: downloadmetaurl = metrixDefaults.URL_GET_SKINPART_META_UPDATE + "&id=" + id metafile = metrixCore.getWeb(downloadmetaurl, True) dom = parseString(metafile) store_date_modified = "" for skinpart in dom.getElementsByTagName('entry'): try: store_build = str(skinpart.getAttributeNode('build').nodeValue) except: store_build = local_build version = str(skinpart.getAttributeNode('version').nodeValue) metrixTools.log("Local build: " + local_build + " store build: " + store_build) if store_build > local_build: return True else: return False except Exception, e: return False metrixTools.log("Error checking SkinPart updates!", e) traceback.print_exc()
def installSkinPart(param, actionId): print '[MyMetrix] Installing skinpart: ' + param downloadurl = 'http://connect.mymetrix.de/store/api/?q=get.xml.skinpartxml&id=' downloadmetaurl = 'http://connect.mymetrix.de/store/api/?q=get.xml.skinpartmeta&id=' screenshotpath = 'http://connect.mymetrix.de/store/api/?q=get.pngresized&width=550' screenshotpath_v2 = 'http://connect.mymetrix.de/store/api/?q=v2.get.png&width=550&type=6' item_id = '' item_type = '' author = '' image_id = '' image_token = '' date_modified = '' try: data = metrixCore.getWeb(downloadmetaurl + str(param), False) dom = parseString(data) for entry in dom.getElementsByTagName('entry'): item_id = str(entry.getAttributeNode('id').nodeValue) item_name = str(entry.getAttributeNode('name').nodeValue) item_type = str(entry.getAttributeNode('type').nodeValue) author = str(entry.getAttributeNode('author').nodeValue) image_id = str(entry.getAttributeNode('image_id').nodeValue) image_token = str(entry.getAttributeNode('image_token').nodeValue) date = str(entry.getAttributeNode('date').nodeValue) try: date_modified = str( entry.getAttributeNode('date_modified').nodeValue) except: date_modified = date if item_type == 'bundle': metrix_SkinPartTools.installBundle(item_id, type, author) else: metrix_SkinPartTools.installSkinPart(item_id, type, author, image_id, image_token) showInfo(item_name + _(' successfully installed!')) except Exception as e: print '[MyMetrix] Error installing SkinPart' print '[MyMetrix] ' + str(e) traceback.print_exc()
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 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 submit(self): try: params = { 'group': self.group, 'vote_id': self.vote_id, 'value': self.rating } data = metrixCore.getWeb(self.ratingurl, True, params) if not data: print '[MyMetrix] Error contacting server' dom = parseString(data) for design in dom.getElementsByTagName('entry'): status = str(design.getAttributeNode('status').nodeValue) code = str(design.getAttributeNode('code').nodeValue) if status == 'error': if code == '103': self.showInfo('Already voted!') else: self.showInfo('Thank you!') self.close() except: print '[MyMetrix] Error submitting rating' self.close()
def isUpdateAvailable(id, local_data_modified): try: downloadmetaurl = 'http://connect.mymetrix.de/store/api/?q=get.xml.skinpartmeta&id=' + id metafile = metrixCore.getWeb(downloadmetaurl, True) dom = parseString(metafile) store_date_modified = '' for design in dom.getElementsByTagName('entry'): try: store_date_modified = str( design.getAttributeNode('date_modified').nodeValue) except: store_date_modified = local_data_modified if time.strptime(local_data_modified, '%d.%m.%Y') < time.strptime( store_date_modified, '%d.%m.%Y'): return True return False except Exception as e: print '[MyMetrix] ' + str(e) traceback.print_exc() downloadSkinPartRenderer(id) downloadSkinPartConverter(id) downloadSkinPartImages(id)
def getUpdatedFiles(): metrixTools.log("Searching update for build "+metrixDefaults.BUILD+ "...") data = metrixCore.getWeb(metrixDefaults.URL_GET_UPDATE_FILES,True) dom = parseString(data) for update in dom.getElementsByTagName('update'): build = str(update.getAttributeNode('build').nodeValue) metrixTools.log("Lastest release: build "+build) if build > metrixDefaults.BUILD: for files in update.getElementsByTagName('file'): update = False path = str(files.getAttributeNode('path').nodeValue) url = str(files.getAttributeNode('url').nodeValue) date_modified = int(files.getAttributeNode('date_modified').nodeValue) if not fileExists(path): update = True else: if int(date_modified) > int(os.path.getmtime(path)): update = True if update: metrixTools.downloadFile(url,path,forceOverwrite=True) config.plugins.MetrixUpdater.RebootRequired.value = True config.plugins.MetrixUpdater.UpdatePopup_Self.value = True metrixTools.downloadFile(metrixDefaults.URL_IMAGE_LOADING,metrixDefaults.URI_IMAGE_LOADING,forceOverwrite = True) metrixTools.downloadFile(metrixDefaults.URL_IMAGE_SPONSOR,metrixDefaults.URI_IMAGE_SPONSOR,forceOverwrite = True)