Ejemplo n.º 1
0
						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
			
		for screen in skinNode.getElementsByTagName('screen'):
			screenname = str(screen.getAttributeNode('name').nodeValue)
			metrixTools.callOnMainThread(self["output"].setText,_(str("Checking compatibility for "+screenname)))
			screen = skinPartIsCompatible(screen)
		
		metrixTools.callOnMainThread(self.writeFile,skindom)
		
		

	def writeFile(self,skindom):
		try:
			self["output"].setText(_("Writing skin file, please wait..."))
			oldfilename = config.plugins.MyMetrix.Templates.value.split("/")[-1]
			file =  config.plugins.MyMetrix.Templates.value.replace(oldfilename,"skin."+config.plugins.MyMetrix.SkinName.value + ".xml")
			path = os.path.dirname(file)	
			if not os.path.exists(path):
				os.makedirs(path)	
			metrix_SkinPartTools.writeSkinFile(skindom,file)
		
Ejemplo n.º 2
0
    def generateSkin(self):
        screennames = []
        screennames = self.getSkinPartsScreennames(metrixDefaults.pathRoot() +
                                                   'skinparts/screens/active/')
        self['output'].setText(_(str('Reading template file')))
        skindom = parse(metrixDefaults.pathRoot() + 'skintemplates/' +
                        config.plugins.MyMetrix.templateFile.value)
        skinNode = skindom.getElementsByTagName('skin')[0]
        self['output'].setText(_(str('Setting colors')))
        self.setColor(skinNode)
        for screen in skindom.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            self['output'].setText(_(str('Checking screen ' + screenname)))
            if screenname in screennames:
                self['output'].setText(
                    _(str('Removing default screen ' + screenname)))
                parentNode = screen.parentNode
                parentNode.removeChild(screen)

        path = metrixDefaults.pathRoot() + 'skinparts/screens/active/'
        dirs = listdir(path)
        for dir in dirs:
            self['output'].setText(_(str('Parsing SkinPart Screens')))
            try:
                screendom = parse(path + '/' + dir + '/data.xml')
                customscreen = skindom.importNode(
                    screendom.getElementsByTagName('screen')[0], True)
                skinNode.appendChild(customscreen)
            except:
                pass

        path = metrixDefaults.pathRoot() + 'skinparts/widgets/active/'
        dirs = listdir(path)
        for dir in dirs:
            try:
                widgetdom = parse(path + '/' + dir + '/data.xml')
                widget = widgetdom.getElementsByTagName('skinpartwidget')[0]
                widgetscreenname = str(
                    widget.getAttributeNode('screenname').nodeValue)
                self['output'].setText(
                    _(str('Parsing SkinPart Widget for ' + widgetscreenname)))
                for screen in skinNode.getElementsByTagName('screen'):
                    screenname = str(screen.getAttributeNode('name').nodeValue)
                    if screenname == widgetscreenname:
                        for child in widget.childNodes:
                            childimport = skindom.importNode(child, True)
                            screen.appendChild(childimport)

                        break

            except:
                pass

        for screen in skindom.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            self['output'].setText(
                _(str('Setting ProgressBars for ' + screenname + ' screen')))
            try:
                for widget in screen.getElementsByTagName('widget'):
                    try:
                        pixmap = widget.getAttributeNode('pixmap').nodeValue
                        if pixmap == 'MetrixHD/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', 'MetrixHD/colors/' +
                                config.plugins.MyMetrix.Color.ProgressBar.
                                value.replace('#', '') + '.png')
                        elif pixmap == '%METRIX:PROGRESSBAR:COLOR:WHITE%':
                            widget.setAttribute(
                                'pixmap', 'MetrixHD/colors/00ffffff.png')
                    except:
                        pass

            except:
                pass

        for screen in skinNode.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            self['output'].setText(
                _(str('Checking compatibility for ' + screenname)))
            screen = skinPartIsCompatible(screen)

        self['output'].setText(_(str('Writing skin file, please wait...')))
        file = '/usr/share/enigma2/MetrixHD/skin.xml'
        path = os.path.dirname(file)
        if not os.path.exists(path):
            os.makedirs(path)
        file = open(path + '/skin.xml', 'w')
        file.write(skindom.toxml())
        file.close()
        try:
            self['output'].setText(_(str('Activating MetrixHD')))
            config.skin.primary_skin.value = 'MetrixHD/skin.xml'
            config.skin.primary_fallback_skin.value = True
            config.skin.primary_fallback_skin.save()
            config.skin.primary_skin.save()
            configfile.save()
        except:
            print 'Error activating MetrixHD'

        restartbox = self.session.openWithCallback(
            self.restartGUI, MessageBox,
            _('GUI needs a restart to apply a new skin.\nDo you want to Restart the GUI now?'
              ), MessageBox.TYPE_YESNO)
        restartbox.setTitle(_('Restart GUI'))
Ejemplo n.º 3
0
    def generateSkin(self):
        screennames = []
        screennames = self.getSkinPartsScreennames(metrixDefaults.pathRoot() + 'skinparts/screens/active/')
        self['output'].setText(_(str('Reading template file')))
        skindom = parse(metrixDefaults.pathRoot() + 'skintemplates/' + config.plugins.MyMetrix.templateFile.value)
        skinNode = skindom.getElementsByTagName('skin')[0]
        self['output'].setText(_(str('Setting colors')))
        self.setColor(skinNode)
        for screen in skindom.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            self['output'].setText(_(str('Checking screen ' + screenname)))
            if screenname in screennames:
                self['output'].setText(_(str('Removing default screen ' + screenname)))
                parentNode = screen.parentNode
                parentNode.removeChild(screen)

        path = metrixDefaults.pathRoot() + 'skinparts/screens/active/'
        dirs = listdir(path)
        for dir in dirs:
            self['output'].setText(_(str('Parsing SkinPart Screens')))
            try:
                screendom = parse(path + '/' + dir + '/data.xml')
                customscreen = skindom.importNode(screendom.getElementsByTagName('screen')[0], True)
                skinNode.appendChild(customscreen)
            except:
                pass

        path = metrixDefaults.pathRoot() + 'skinparts/widgets/active/'
        dirs = listdir(path)
        for dir in dirs:
            try:
                widgetdom = parse(path + '/' + dir + '/data.xml')
                widget = widgetdom.getElementsByTagName('skinpartwidget')[0]
                widgetscreenname = str(widget.getAttributeNode('screenname').nodeValue)
                self['output'].setText(_(str('Parsing SkinPart Widget for ' + widgetscreenname)))
                for screen in skinNode.getElementsByTagName('screen'):
                    screenname = str(screen.getAttributeNode('name').nodeValue)
                    if screenname == widgetscreenname:
                        for child in widget.childNodes:
                            childimport = skindom.importNode(child, True)
                            screen.appendChild(childimport)

                        break

            except:
                pass

        for screen in skindom.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            self['output'].setText(_(str('Setting ProgressBars for ' + screenname + ' screen')))
            try:
                for widget in screen.getElementsByTagName('widget'):
                    try:
                        pixmap = widget.getAttributeNode('pixmap').nodeValue
                        if pixmap == 'MetrixHD/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', 'MetrixHD/colors/' + config.plugins.MyMetrix.Color.ProgressBar.value.replace('#', '') + '.png')
                        elif pixmap == '%METRIX:PROGRESSBAR:COLOR:WHITE%':
                            widget.setAttribute('pixmap', 'MetrixHD/colors/00ffffff.png')
                    except:
                        pass

            except:
                pass

        for screen in skinNode.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            self['output'].setText(_(str('Checking compatibility for ' + screenname)))
            screen = skinPartIsCompatible(screen)

        self['output'].setText(_(str('Writing skin file, please wait...')))
        file = '/usr/share/enigma2/MetrixHD/skin.xml'
        path = os.path.dirname(file)
        if not os.path.exists(path):
            os.makedirs(path)
        file = open(path + '/skin.xml', 'w')
        file.write(skindom.toxml())
        file.close()
        try:
            self['output'].setText(_(str('Activating MetrixHD')))
            config.skin.primary_skin.value = 'MetrixHD/skin.xml'
            config.skin.primary_fallback_skin.value = True
            config.skin.primary_fallback_skin.save()
            config.skin.primary_skin.save()
            configfile.save()
        except:
            print 'Error activating MetrixHD'

        restartbox = self.session.openWithCallback(self.restartGUI, MessageBox, _('GUI needs a restart to apply a new skin.\nDo you want to Restart the GUI now?'), MessageBox.TYPE_YESNO)
        restartbox.setTitle(_('Restart GUI'))
Ejemplo n.º 4
0
def generateSkin(actionId):
    try:
        print '[MyMetrix] Generating Skin via web'
        showInfo(_('Generating skin!'))
        screennames = []
        screennames = getSkinPartsScreennames(metrixDefaults.pathRoot() + 'skinparts/screens/active/')
        skindom = parse(metrixDefaults.pathRoot() + 'skintemplates/' + config.plugins.MyMetrix.templateFile.value)
        skinNode = skindom.getElementsByTagName('skin')[0]
        setColor(skinNode)
        for screen in skindom.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            if screenname in screennames:
                parentNode = screen.parentNode
                parentNode.removeChild(screen)

        path = metrixDefaults.pathRoot() + 'skinparts/screens/active/'
        dirs = listdir(path)
        for dir in dirs:
            try:
                screendom = parse(path + '/' + dir + '/data.xml')
                customscreen = skindom.importNode(screendom.getElementsByTagName('screen')[0], True)
                skinNode.appendChild(customscreen)
            except:
                pass

        path = metrixDefaults.pathRoot() + 'skinparts/widgets/active/'
        dirs = listdir(path)
        for dir in dirs:
            try:
                widgetdom = parse(path + '/' + dir + '/data.xml')
                widget = widgetdom.getElementsByTagName('skinpartwidget')[0]
                widgetscreenname = str(widget.getAttributeNode('screenname').nodeValue)
                for screen in skinNode.getElementsByTagName('screen'):
                    screenname = str(screen.getAttributeNode('name').nodeValue)
                    if screenname == widgetscreenname:
                        for child in widget.childNodes:
                            childimport = skindom.importNode(child, True)
                            screen.appendChild(childimport)

                        break

            except:
                pass

        for screen in skindom.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            for widget in screen.getElementsByTagName('widget'):
                try:
                    pixmap = str(widget.getAttributeNode('pixmap').nodeValue)
                    if pixmap == 'MetrixHD/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', 'MetrixHD/colors/' + config.plugins.MyMetrix.Color.ProgressBar.value.replace('#', '') + '.png')
                    elif pixmap == '%METRIX:PROGRESSBAR:COLOR:WHITE%':
                        widget.setAttribute('pixmap', 'MetrixHD/colors/00ffffff.png')
                except:
                    pass

        for screen in skindom.getElementsByTagName('screen'):
            screen = skinPartIsCompatible(screen)

        file = '/usr/share/enigma2/MetrixHD/skin.xml'
        path = os.path.dirname(file)
        if not os.path.exists(path):
            os.makedirs(path)
        file = open(path + '/skin.xml', 'w')
        file.write(skindom.toxml())
        file.close()
        try:
            config.skin.primary_skin.value = 'MetrixHD/skin.xml'
            config.skin.primary_skin.save()
            config.skin.primary_fallback_skin.value = True
            config.skin.primary_fallback_skin.save()
            configfile.save()
            showInfo(_('Skin successfully generated!'))
        except Exception as e:
            print '[MyMetrix] ' + str(e)
            traceback.print_exc()
            print '[MyMetrix] Error activating MetrixHD'

    except Exception as e:
        print '[MyMetrix] ' + str(e)
        traceback.print_exc()
Ejemplo n.º 5
0
def generateSkin(actionId):
    try:
        print '[MyMetrix] Generating Skin via web'
        showInfo(_('Generating skin!'))
        screennames = []
        screennames = getSkinPartsScreennames(metrixDefaults.pathRoot() +
                                              'skinparts/screens/active/')
        skindom = parse(metrixDefaults.pathRoot() + 'skintemplates/' +
                        config.plugins.MyMetrix.templateFile.value)
        skinNode = skindom.getElementsByTagName('skin')[0]
        setColor(skinNode)
        for screen in skindom.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            if screenname in screennames:
                parentNode = screen.parentNode
                parentNode.removeChild(screen)

        path = metrixDefaults.pathRoot() + 'skinparts/screens/active/'
        dirs = listdir(path)
        for dir in dirs:
            try:
                screendom = parse(path + '/' + dir + '/data.xml')
                customscreen = skindom.importNode(
                    screendom.getElementsByTagName('screen')[0], True)
                skinNode.appendChild(customscreen)
            except:
                pass

        path = metrixDefaults.pathRoot() + 'skinparts/widgets/active/'
        dirs = listdir(path)
        for dir in dirs:
            try:
                widgetdom = parse(path + '/' + dir + '/data.xml')
                widget = widgetdom.getElementsByTagName('skinpartwidget')[0]
                widgetscreenname = str(
                    widget.getAttributeNode('screenname').nodeValue)
                for screen in skinNode.getElementsByTagName('screen'):
                    screenname = str(screen.getAttributeNode('name').nodeValue)
                    if screenname == widgetscreenname:
                        for child in widget.childNodes:
                            childimport = skindom.importNode(child, True)
                            screen.appendChild(childimport)

                        break

            except:
                pass

        for screen in skindom.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            for widget in screen.getElementsByTagName('widget'):
                try:
                    pixmap = str(widget.getAttributeNode('pixmap').nodeValue)
                    if pixmap == 'MetrixHD/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',
                            'MetrixHD/colors/' + config.plugins.MyMetrix.Color.
                            ProgressBar.value.replace('#', '') + '.png')
                    elif pixmap == '%METRIX:PROGRESSBAR:COLOR:WHITE%':
                        widget.setAttribute('pixmap',
                                            'MetrixHD/colors/00ffffff.png')
                except:
                    pass

        for screen in skindom.getElementsByTagName('screen'):
            screen = skinPartIsCompatible(screen)

        file = '/usr/share/enigma2/MetrixHD/skin.xml'
        path = os.path.dirname(file)
        if not os.path.exists(path):
            os.makedirs(path)
        file = open(path + '/skin.xml', 'w')
        file.write(skindom.toxml())
        file.close()
        try:
            config.skin.primary_skin.value = 'MetrixHD/skin.xml'
            config.skin.primary_skin.save()
            config.skin.primary_fallback_skin.value = True
            config.skin.primary_fallback_skin.save()
            configfile.save()
            showInfo(_('Skin successfully generated!'))
        except Exception as e:
            print '[MyMetrix] ' + str(e)
            traceback.print_exc()
            print '[MyMetrix] Error activating MetrixHD'

    except Exception as e:
        print '[MyMetrix] ' + str(e)
        traceback.print_exc()
Ejemplo n.º 6
0
                        elif pixmap == "%METRIX:PROGRESSBAR:COLOR:WHITE%":
                            widget.setAttribute(
                                "pixmap",
                                metrixDefaults.getTemplateFiles() +
                                "/colors/00ffffff.png")
                    except:
                        pass
            except:
                pass

        for screen in skinNode.getElementsByTagName('screen'):
            screenname = str(screen.getAttributeNode('name').nodeValue)
            metrixTools.callOnMainThread(
                self["output"].setText,
                _(str("Checking compatibility for " + screenname)))
            screen = skinPartIsCompatible(screen)

        metrixTools.callOnMainThread(self.writeFile, skindom)

    def writeFile(self, skindom):
        try:
            self["output"].setText(_("Writing skin file, please wait..."))
            oldfilename = config.plugins.MyMetrix.Templates.value.split(
                "/")[-1]
            file = config.plugins.MyMetrix.Templates.value.replace(
                oldfilename,
                "skin." + config.plugins.MyMetrix.SkinName.value + ".xml")
            path = os.path.dirname(file)
            if not os.path.exists(path):
                os.makedirs(path)
            metrix_SkinPartTools.writeSkinFile(skindom, file)