コード例 #1
0
ファイル: metrix_SkinPartTools.py プロジェクト: HDMU/Skins
def checkSkinPartUpdates(path, isActive=True):
    dirs = listdir(path)
    for dir in dirs:
        try:
            file = open(path + "/" + dir + "/meta.xml", "r")
            data = file.read()
            file.close()
            dom = parseString(data)
            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)
                description = str(design.getAttributeNode("description").nodeValue)
                date = str(design.getAttributeNode("date").nodeValue)
                try:
                    date_modified = str(design.getAttributeNode("date_modified").nodeValue)
                except:
                    date_modified = date

                if isUpdateAvailable(id, date_modified):
                    installSkinPart(id, type, author, image_id, image_token, date_modified, isActive)
                    metrixConnector.showInfo(name + _(" successfully updated!"))

        except:
            pass
コード例 #2
0
def installPackage(url,force=False,silent=False,id=0,build=0):
	downloadDir = '/tmp/openstore/'
	if not os.path.exists(downloadDir):
		os.makedirs(downloadDir)
	metrixTools.log("Installing package "+url,None,"OpenStore")
	packagefile = metrixTools.downloadFile(url,downloadDir + 'package.ipk',forceOverwrite=True)
	packagename = getPackageName(downloadDir,"package.ipk")
	if force:
		cmdStatus = runCommand("opkg install --force-overwrite '"+packagefile+"'")
	else:
		cmdStatus = runCommand("opkg install '"+packagefile+"'")
	if cmdStatus[0] == True:
		if not id == 0:
			metrixDefaults.cfgset(metrixDefaults.CONFIG_INSTALLEDPACKAGES,id,"id",id)
			try:
				metrixDefaults.cfgset(metrixDefaults.CONFIG_INSTALLEDPACKAGES,id,"name",packagename)
			except:
				pass
			metrixDefaults.cfgset(metrixDefaults.CONFIG_INSTALLEDPACKAGES,id,"build",build)
			metrixDefaults.cfgset(metrixDefaults.CONFIG_INSTALLEDPACKAGES,id,"url",url)
		config.plugins.MetrixUpdater.Reboot.value = 1
		config.plugins.MetrixUpdater.save()    
		configfile.save()
		if not silent:
			metrixConnector.showInfo(_("Package successfully installed!"))
		return True
	else:
		if not silent:
			metrixConnector.showInfo(_("Error installing Package!"),MessageBox.TYPE_ERROR)
		return False
	if os.path.exists(downloadDir):
		os.removedirs(downloadDir)
	syncPackages()
コード例 #3
0
def checkSkinPartUpdates(path,isActive=True):
	dirs = listdir( path )
	for dir in dirs:
		try:
			#print dir
			file = open(path+"/"+dir+"/meta.xml", "r")
			data = file.read()
			file.close()	
			dom = parseString(data)
			for skinpart in dom.getElementsByTagName('entry'):
				id = str(skinpart.getAttributeNode('id').nodeValue)
				name = str(skinpart.getAttributeNode('name').nodeValue)
				type = str(skinpart.getAttributeNode('type').nodeValue)
				author = str(skinpart.getAttributeNode('author').nodeValue)
				description = str(skinpart.getAttributeNode('description').nodeValue)
				date = str(skinpart.getAttributeNode('date').nodeValue)
				version = str(skinpart.getAttributeNode('version').nodeValue)
				try:
					build = int(skinpart.getAttributeNode('build').nodeValue)
				except:
					build = 99999 # FOR LEGACY SKINPARTS
				image_link = str(skinpart.getAttributeNode('image_link').nodeValue)
				try:
					date_modified = str(skinpart.getAttributeNode('date_modified').nodeValue)
				except:
					date_modified = date
				if isUpdateAvailable(id,build):
					installSkinPart(id,type,author,image_link,date_modified,isActive,True)
					metrixConnector.showInfo(name+_(" successfully updated!"))
					config.plugins.MetrixUpdater.UpdateAvailable.value = 1
					config.plugins.MetrixUpdater.save()    
					
		except:
			pass
コード例 #4
0
def uninstallPackage(packageName,id=0,silent=False):
	metrixTools.log("Uninstalling package "+packageName,None,"OpenStore")
	cmdStatus = runCommand("opkg remove '"+packageName+"'")
	if cmdStatus[0] == True: #Command without errorcode
		config.plugins.MetrixUpdater.Reboot.value = 1
		config.plugins.MetrixUpdater.save()    
		configfile.save()
		if not id == 0:
			metrixDefaults.cfgremovesection(metrixDefaults.CONFIG_INSTALLEDPACKAGES,id)
		if not silent:
			metrixConnector.showInfo(cmdStatus[1])
		else:
			return True
	else:
		if not silent:
			metrixConnector.showInfo(_("Error uninstalling Package!"),MessageBox.TYPE_ERROR)
		else:
			return False
	syncPackages()