def theme(self, name, theme, over=False): installtheme = False if not theme: themefile = check.check_build(name, 'theme') response = tools.open_url(themefile, check=True) if response: from resources.libs.gui.build_menu import BuildMenu themes = BuildMenu().theme_count(name, False) if len(themes) > 0: if self.dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}]The Build [COLOR {1}]{2}[/COLOR] comes with [COLOR {3}]{4}[/COLOR] different themes" .format(CONFIG.COLOR2, CONFIG.COLOR1, name, CONFIG.COLOR1, len(themes)) + '\n' + "Would you like to install one now?[/COLOR]", yeslabel= "[B][COLOR springgreen]Install Theme[/COLOR][/B]", nolabel="[B][COLOR red]Cancel Themes[/COLOR][/B]"): logging.log("Theme List: {0}".format(str(themes))) ret = self.dialog.select(CONFIG.ADDONTITLE, themes) logging.log("Theme install selected: {0}".format(ret)) if not ret == -1: theme = themes[ret] installtheme = True else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: Cancelled![/COLOR]'. format(CONFIG.COLOR2)) return else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: Cancelled![/COLOR]'. format(CONFIG.COLOR2)) return else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: None Found![/COLOR]'.format( CONFIG.COLOR2)) else: installtheme = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}]Would you like to install the theme:'.format( CONFIG.COLOR2) + ' \n' + '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, theme) + '\n' + 'for [COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]'.format( CONFIG.COLOR1, name, check.check_build(name, 'version')), yeslabel="[B][COLOR springgreen]Install Theme[/COLOR][/B]", nolabel="[B][COLOR red]Cancel Themes[/COLOR][/B]") if installtheme: themezip = check.check_theme(name, theme, 'url') zipname = name.replace('\\', '').replace('/', '').replace( ':', '').replace('*', '').replace('?', '').replace('"', '').replace( '<', '').replace('>', '').replace('|', '') response = tools.open_url(themezip, check=True) if not response: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: Invalid Zip Url![/COLOR]'. format(CONFIG.COLOR2)) return False self.dialogProgress.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1, zipname) + ' \n' + 'Please Wait') lib = os.path.join(CONFIG.PACKAGES, '{0}.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(themezip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return self.dialogProgress.update(0, '\n' + "Installing {0}".format(name)) title = '[COLOR {0}][B]Installing Theme:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, theme) self.dialogProgress.update(0, title + '\n' + 'Please Wait') percent, errors, error = extract.all(lib, CONFIG.HOME, title=title) CONFIG.set_setting('buildtheme', theme) logging.log('INSTALLED {0}: [ERRORS:{1}]'.format(percent, errors)) self.dialogProgress.close() #db.force_check_updates(over=True) installed = db.grab_addons(lib) db.addon_database(installed, 1, True) xbmc.executebuiltin("ReloadSkin()") xbmc.sleep(1000) xbmc.executebuiltin("Container.Refresh()") else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Theme Install: Cancelled![/COLOR]'.format( CONFIG.COLOR2))
def theme(self, name, theme='', over=False): installtheme = False if not theme: themefile = check.check_build(name, 'theme') response = tools.open_url(themefile, check=True) if response: from resources.libs.gui.build_menu import BuildMenu themes = BuildMenu().theme_count(name, False) if len(themes) > 0: if self.dialog.yesno( CONFIG.ADDONTITLE, "[COLOR {0}][B]La Build [COLOR {1}]{2}[/COLOR] viene con [COLOR {3}]{4}[/COLOR] Parches diferentes[/B]" .format(CONFIG.COLOR2, CONFIG.COLOR1, name, CONFIG.COLOR1, len(themes)) + '\n\n' + "Le gustaria instalar uno ahora?[/COLOR]", yeslabel= "[B][COLOR cyan]Instalar Parche[/COLOR][/B]", nolabel="[B][COLOR red]Cancelar Parche[/COLOR][/B]" ): logging.log("Lista de Parches: {0}".format( str(themes))) ret = self.dialog.select(CONFIG.ADDONTITLE, themes) logging.log( "[B]Selecciona un Parche para Instalar:[/B] {0}". format(ret)) if not ret == -1: theme = themes[ret] installtheme = True else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Instalación:[/COLOR] [COLOR gold]Cancelado![/COLOR]' .format(CONFIG.COLOR2)) return else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Instalación Parche:[/COLOR] [COLOR gold]Cancelado![/COLOR]' .format(CONFIG.COLOR2)) return else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Instalación Parche:[/COLOR] [COLOR gold]Nada Encontrado![/COLOR]' .format(CONFIG.COLOR2)) else: installtheme = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}][B]Te gustaría instalar uno de los Parches que hay en:[/B]' .format(CONFIG.COLOR2) + ' \n' + '[COLOR dodgerblue][B]PARCHES MATRIX[/B][/COLOR]'.format( CONFIG.COLOR1, theme) + '\n' + '[B]para [COLOR {0}]{1} v{2}[/COLOR]?[/B][/COLOR]'.format( CONFIG.COLOR1, name, check.check_build(name, 'version')), yeslabel="[B][COLOR cyan]Instalar Parche[/COLOR][/B]", nolabel="[B][COLOR red]Cancelar Parche[/COLOR][/B]") if installtheme: themezip = check.check_theme(name, theme, 'url') zipname = name.replace('\\', '').replace('/', '').replace( ':', '').replace('*', '').replace('?', '').replace('"', '').replace( '<', '').replace('>', '').replace('|', '') response = tools.open_url(themezip, check=True) if not response: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Instalación Parche:[/COLOR] [COLOR gold]Url Zip Inválido![/COLOR]' .format(CONFIG.COLOR2)) return False self.dialogProgress.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Descargando:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1, zipname) + ' \n' + 'Espere por Favor') lib = os.path.join(CONFIG.PACKAGES, '{0}.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(themezip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return self.dialogProgress.update(0, '\n' + "Instalando {0}".format(name)) from resources.libs import skin from resources.libs import test title = '[COLOR {0}][B]Instalando Parche:[/B][/COLOR] [COLOR {1}]{2}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, theme) self.dialogProgress.update(0, title + '\n' + 'Espere por Favor') percent, errors, error = extract.all(lib, CONFIG.HOME, title=title) CONFIG.set_setting('buildtheme', theme) logging.log('INSTALADO {0}: [ERRORES:{1}]'.format(percent, errors)) self.dialogProgress.close() installed = db.grab_addons(lib) db.addon_database(installed, 1, True) xbmc.executebuiltin("ReloadSkin()") xbmc.sleep(1000) xbmc.executebuiltin("Container.Refresh()") else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Instalación Parche:[/COLOR] [COLOR gold]Cancelado![/COLOR]' .format(CONFIG.COLOR2))