def build(self, name, over=False): # if action == 'normal': # if CONFIG.KEEPTRAKT == 'true': # from resources.libs import traktit # traktit.auto_update('all') # CONFIG.set_setting('traktnextsave', tools.get_date(days=3, formatted=True)) # if CONFIG.KEEPDEBRID == 'true': # from resources.libs import debridit # debridit.auto_update('all') # CONFIG.set_setting('debridnextsave', tools.get_date(days=3, formatted=True)) # if CONFIG.KEEPLOGIN == 'true': # from resources.libs import loginit # loginit.auto_update('all') # CONFIG.set_setting('loginnextsave', tools.get_date(days=3, formatted=True)) temp_kodiv = int(CONFIG.KODIV) buildv = int(float(check.check_build(name, 'kodi'))) if not temp_kodiv == buildv: warning = True else: warning = False if warning: yes_pressed = self.dialog.yesno( "{0} - [COLOR red]WARNING!![/COLOR]".format(CONFIG.ADDONTITLE), '[COLOR {0}]There is a chance that the skin will not appear correctly' .format(CONFIG.COLOR2) + '\n' + 'When installing a {0} build on a Kodi {1} install'.format( check.check_build(name, 'kodi'), CONFIG.KODIV) + '\n' + 'Would you still like to install: [COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]' .format(CONFIG.COLOR1, name, check.check_build( name, 'version')), nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Yes, Install[/COLOR][/B]') else: if over: yes_pressed = 1 else: yes_pressed = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}]Would you like to Download and Install: '. format(CONFIG.COLOR2) + '[COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]'.format( CONFIG.COLOR1, name, check.check_build( name, 'version')), nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Yes, Install[/COLOR][/B]') if yes_pressed: CONFIG.clear_setting('build') buildzip = check.check_build(name, 'url') zipname = name.replace('\\', '').replace('/', '').replace( ':', '').replace('*', '').replace('?', '').replace('"', '').replace( '<', '').replace('>', '').replace('|', '') self.dialogProgress.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Downloading:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) + '\n' + 'Please Wait') lib = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(buildzip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return yes_fresh = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}][COLOR {1}]Do you wish to erase all data before installing?[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1), nolabel='[B][COLOR red]No Thanks[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Fresh Install[/COLOR][/B]') if yes_fresh: install.wipe() skin.look_and_feel_data('save') title = '[COLOR {0}][B]Installing:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) self.dialogProgress.update(0, title + '\n' + 'Please Wait') percent, errors, error = extract.all(lib, CONFIG.HOME, title=title) skin.skin_to_default('Build Install') if int(float(percent)) > 0: db.fix_metas() CONFIG.set_setting('buildname', name) CONFIG.set_setting('buildversion', check.check_build(name, 'version')) CONFIG.set_setting('buildtheme', '') CONFIG.set_setting('latestversion', check.check_build(name, 'version')) CONFIG.set_setting( 'nextbuildcheck', tools.get_date(days=CONFIG.UPDATECHECK, formatted=True)) CONFIG.set_setting('installed', 'true') CONFIG.set_setting('extract', percent) CONFIG.set_setting('errors', errors) logging.log('INSTALLED {0}: [ERRORS:{1}]'.format( percent, errors)) try: os.remove(lib) except: pass if int(float(errors)) > 0: yes_pressed = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}][COLOR {1}]{2} v{3}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) + '\n' + 'Completed: [COLOR {0}]{1}{2}[/COLOR] [Errors:[COLOR {3}]{4}[/COLOR]]' .format(CONFIG.COLOR1, percent, '%', CONFIG.COLOR1, errors) + '\n' + 'Would you like to view the errors?[/COLOR]', nolabel='[B][COLOR red]No Thanks[/COLOR][/B]', yeslabel='[B][COLOR springgreen]View Errors[/COLOR][/B]' ) if yes_pressed: from resources.libs.gui import window window.show_text_box("Viewing Build Install Errors", error) self.dialogProgress.close() from resources.libs.gui.build_menu import BuildMenu #themecount = BuildMenu().theme_count(name) #if themecount > 0: #self.theme(name, 'theme') db.addon_database(CONFIG.ADDON_ID, 1) #db.force_check_updates(over=True) self.dialog.ok( CONFIG.ADDONTITLE, "[COLOR {0}]To save changes you now need to force close Kodi, Press OK to force close Kodi[/COLOR]" .format(CONFIG.COLOR2)) tools.kill_kodi(over=True) else: from resources.libs.gui import window window.show_text_box("Viewing Build Install Errors", error) else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Build Install: Cancelled![/COLOR]'.format( CONFIG.COLOR2))
def _backup_build(name=""): dialog = xbmcgui.Dialog() progress_dialog = xbmcgui.DialogProgress() if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]Are you sure you wish to backup the current build?[/COLOR]".format(CONFIG.COLOR2), nolabel="[B][COLOR red]Cancel Backup[/COLOR][/B]", yeslabel="[B][COLOR springgreen]Backup Build[/COLOR][/B]"): if name == "": name = tools.get_keyboard("", "Please enter a name for the build zip") if not name: return False name = name.replace('\\', '').replace('/', '').replace(':', '').replace('*', '').replace('?', '').replace( '"', '').replace('<', '').replace('>', '').replace('|', '') name = quote_plus(name) tempzipname = '' zipname = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(name)) for_progress = 0 ITEM = [] exclude_dirs = CONFIG.EXCLUDE_DIRS if not dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]Do you want to include your addon_data folder?".format(CONFIG.COLOR2), "This contains [COLOR {0}]ALL[/COLOR] add-on settings including passwords but may also contain important information such as skin shortcuts. We recommend [COLOR {0}]MANUALLY[/COLOR] removing the addon_data folders that aren\'t required.".format(CONFIG.COLOR1, CONFIG.COLOR1), "[COLOR {0}]{1}[/COLOR] addon_data is ignored[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDON_ID), yeslabel='[B][COLOR springgreen]Include data[/COLOR][/B]', nolabel='[B][COLOR red]Don\'t Include[/COLOR][/B]'): exclude_dirs.append('addon_data') tools.convert_special(CONFIG.HOME, True) # tools.ascii_check(CONFIG.HOME, True) extractsize = 0 try: zipf = zipfile.ZipFile(xbmc.translatePath(zipname), mode='w') except: try: tempzipname = os.path.join(CONFIG.PACKAGES, '{0}.zip'.format(name)) zipf = zipfile.ZipFile(tempzipname, mode='w') except: logging.log("Unable to create {0}.zip".format(name), level=xbmc.LOGERROR) if dialog.yesno(CONFIG.ADDONTITLE, "[COLOR {0}]We are unable to write to the current backup directory, would you like to change the location?[/COLOR]".format(CONFIG.COLOR2), yeslabel="[B][COLOR springgreen]Change Directory[/COLOR][/B]", nolabel="[B][COLOR red]Cancel[/COLOR][/B]"): CONFIG.open_settings() return else: return progress_dialog.create("[COLOR {0}]{1}[/COLOR][COLOR {2}]: Creating Zip[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE, CONFIG.COLOR2), "[COLOR {0}]Creating backup zip".format(CONFIG.COLOR2), "", "Please Wait...[/COLOR]") for base, dirs, files in os.walk(CONFIG.HOME): dirs[:] = [d for d in dirs if d not in exclude_dirs] files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: ITEM.append(file) N_ITEM = len(ITEM) picture = [] music = [] video = [] programs = [] repos = [] scripts = [] skins = [] fold = glob.glob(os.path.join(CONFIG.ADDONS, '*/')) idlist = [] binaries = [] binidlist = [] for folder in sorted(fold, key=lambda x: x): foldername = os.path.split(folder[:-1])[1] if foldername == 'packages': continue binaryid, binaryname = db.find_binary_addons(addon=foldername) if binaryid: binaries.append(binaryname) binidlist.append(binaryid) xml = os.path.join(folder, 'addon.xml') if os.path.exists(xml): a = tools.read_from_file(xml) prov = re.compile("<provides>(.+?)</provides>").findall(a) match = tools.parse_dom(prov, 'addon', ret='id') addid = foldername if len(match) == 0 else match[0] if addid in idlist: continue idlist.append(addid) try: add = xbmcaddon.Addon(id=addid) aname = add.getAddonInfo('name') aname = aname.replace('[', '<').replace(']', '>') aname = str(re.sub('<[^<]+?>', '', aname)).lstrip() except: aname = foldername if len(prov) == 0: if foldername.startswith('skin'): skins.append(aname) elif foldername.startswith('repo'): repos.append(aname) else: scripts.append(aname) continue if not (prov[0]).find('executable') == -1: programs.append(aname) if not (prov[0]).find('video') == -1: video.append(aname) if not (prov[0]).find('audio') == -1: music.append(aname) if not (prov[0]).find('image') == -1: picture.append(aname) db.fix_metas() binarytxt = _backup_binaries(binidlist) for base, dirs, files in os.walk(CONFIG.HOME): dirs[:] = [d for d in dirs if d not in exclude_dirs] files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: try: for_progress += 1 progress = tools.percentage(for_progress, N_ITEM) progress_dialog.update(int(progress), '[COLOR {0}]Creating backup zip: [COLOR {1}]{2}[/COLOR] / [COLOR {3}]{4}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, for_progress, CONFIG.COLOR1, N_ITEM), '[COLOR {0}]{1}[/COLOR]'.format(CONFIG.COLOR1, file), '') fn = os.path.join(base, file) if file in CONFIG.LOGFILES: logging.log("[Back Up] Type = build: Ignore {0} - Log File".format(file)) continue elif os.path.join(base, file) in CONFIG.EXCLUDE_FILES: logging.log("[Back Up] Type = build: Ignore {0} - Excluded File".format(file)) continue elif os.path.join('addons', 'packages') in fn: logging.log("[Back Up] Type = build: Ignore {0} - Packages Folder".format(file)) continue elif file.endswith('.csv'): logging.log("[Back Up] Type = build: Ignore {0} - CSV File".format(file)) continue elif file.endswith('.pyo'): continue elif file.endswith('.db') and 'Database' in base: temp = file.replace('.db', '') temp = ''.join([i for i in temp if not i.isdigit()]) if temp in CONFIG.DB_FILES: if not file == db.latest_db(temp): logging.log("[Back Up] Type = build: Ignore {0} - DB File".format(file)) continue skipbinary = False if len(binidlist) > 0: for id in binidlist: id = os.path.join(CONFIG.ADDONS, id) if id in fn: skipbinary = True if skipbinary: logging.log("[Back Up] Type = build: Ignore {0} - Binary Add-on".format(file)) continue try: zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) extractsize += os.path.getsize(fn) except Exception as e: logging.log("[Back Up] Type = build: Unable to backup {0}".format(file)) logging.log("{0} / {1}".format(Exception, e)) if progress_dialog.iscanceled(): progress_dialog.close() logging.log_notify("[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, CONFIG.ADDONTITLE), "[COLOR {0}]Backup Cancelled[/COLOR]".format(CONFIG.COLOR2)) sys.exit() except Exception as e: logging.log("[Back Up] Type = build: Unable to backup {0}".format(file)) logging.log("Build Backup Error: {0}".format(str(e))) if 'addon_data' in exclude_dirs: match = glob.glob(os.path.join(CONFIG.ADDON_DATA, 'skin.*', '')) for fold in match: fd = os.path.split(fold[:-1])[1] if fd not in ['skin.confluence', 'skin.estuary', 'skin.estouchy']: for base, dirs, files in os.walk(os.path.join(CONFIG.ADDON_DATA, fold)): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) extractsize += os.path.getsize(fn) xml = os.path.join(CONFIG.ADDONS, fd, 'addon.xml') if os.path.exists(xml): matchxml = tools.parse_dom(tools.read_from_file(xml), 'import', ret='addon') if 'script.skinshortcuts' in matchxml: for base, dirs, files in os.walk(os.path.join(CONFIG.ADDON_DATA, 'script.skinshortcuts')): files[:] = [f for f in files if f not in CONFIG.EXCLUDE_FILES] for file in files: fn = os.path.join(base, file) zipf.write(fn, fn[len(CONFIG.HOME):], zipfile.ZIP_DEFLATED) extractsize += os.path.getsize(fn) zipf.close() xbmc.sleep(500) progress_dialog.close() backup('guifix', name) if not tempzipname == '': success = xbmcvfs.rename(tempzipname, zipname) if success == 0: xbmcvfs.copy(tempzipname, zipname) xbmcvfs.delete(tempzipname) if binarytxt is not None: bintxtpath = os.path.join(CONFIG.USERDATA, binarytxt) xbmcvfs.delete(bintxtpath) _backup_info(name, extractsize, programs, video, music, picture, repos, scripts, binaries) if len(binaries) > 0: dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]The following add-ons were excluded from the backup because they are platform specific:[/COLOR]".format(CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, ', '.join(binaries))) dialog.ok(CONFIG.ADDONTITLE, "[COLOR {0}]{1}[/COLOR] [COLOR {2}]Backup successful:[/COLOR]".format(CONFIG.COLOR1, name, CONFIG.COLOR2), "[COLOR {0}]{1}[/COLOR]".format(CONFIG.COLOR1, zipname))
def build(self, name, over=False): # if action == 'normal': # if CONFIG.KEEPTRAKT == 'true': # from resources.libs import traktit # traktit.auto_update('all') # CONFIG.set_setting('traktnextsave', tools.get_date(days=3, formatted=True)) # if CONFIG.KEEPDEBRID == 'true': # from resources.libs import debridit # debridit.auto_update('all') # CONFIG.set_setting('debridnextsave', tools.get_date(days=3, formatted=True)) # if CONFIG.KEEPLOGIN == 'true': # from resources.libs import loginit # loginit.auto_update('all') # CONFIG.set_setting('loginnextsave', tools.get_date(days=3, formatted=True)) temp_kodiv = int(CONFIG.KODIV) buildv = int(float(check.check_build(name, 'kodi'))) if not temp_kodiv == buildv: warning = True else: warning = False if warning: yes_pressed = self.dialog.yesno( "{0} - [COLOR red]ADVERTENCIA!![/COLOR]".format( CONFIG.ADDONTITLE), '[COLOR {0}]Existe la posibilidad de que el Skin no se vea correctamente' .format(CONFIG.COLOR2) + '\n' + 'Al instalar una {0} build en un Kodi {1} instalado'.format( check.check_build(name, 'kodi'), CONFIG.KODIV) + '\n' + 'Todavia te gustaria instalar: [COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]' .format(CONFIG.COLOR1, name, check.check_build( name, 'version')), nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Yes, Install[/COLOR][/B]') else: if over: yes_pressed = 1 else: yes_pressed = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}][B]La Instalación Sobreescribirá los datos de su Kodi Actual ![/B] ' .format(CONFIG.COLOR2) + '\n' + '[COLOR {0}]Le gustaria Descargar e Instalar: '.format( CONFIG.COLOR2) + '[COLOR {0}]{1} v{2} [/COLOR]?[/COLOR]'.format( CONFIG.COLOR1, name, check.check_build( name, 'version')), nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Si, Instalar[/COLOR][/B]') if yes_pressed: CONFIG.clear_setting('build') buildzip = check.check_build(name, 'url') zipname = name.replace('\\', '').replace('/', '').replace( ':', '').replace('*', '').replace('?', '').replace('"', '').replace( '<', '').replace('>', '').replace('|', '') self.dialogProgress.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]Descargando:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) + '\n' + 'Espere por Favor') lib = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(buildzip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return install.wipe() skin.look_and_feel_data('save') title = '[COLOR {0}][B]Instalando:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) self.dialogProgress.update(0, title + '\n' + 'Espere por Favor') percent, errors, error = extract.all(lib, CONFIG.HOME, title=title) skin.skin_to_default('Instalar Build') if int(float(percent)) > 0: db.fix_metas() CONFIG.set_setting('buildname', name) CONFIG.set_setting('buildversion', check.check_build(name, 'version')) CONFIG.set_setting('buildtheme', '') CONFIG.set_setting('latestversion', check.check_build(name, 'version')) CONFIG.set_setting( 'nextbuildcheck', tools.get_date(days=CONFIG.UPDATECHECK, formatted=True)) CONFIG.set_setting('installed', 'true') CONFIG.set_setting('extract', percent) CONFIG.set_setting('errors', errors) logging.log('INSTALADO {0}: [ERRORES:{1}]'.format( percent, errors)) try: os.remove(lib) except: pass if int(float(errors)) > 0: yes_pressed = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}][COLOR {1}]{2} v{3}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) + '\n' + 'Completado: [COLOR {0}]{1}{2}[/COLOR] [Errores:[COLOR {3}]{4}[/COLOR]]' .format(CONFIG.COLOR1, percent, '%', CONFIG.COLOR1, errors) + '\n' + 'Le gustaria ver los errores?[/COLOR]', nolabel='[B][COLOR red]No, Gracias[/COLOR][/B]', yeslabel='[B][COLOR springgreen]Ver Errores[/COLOR][/B]' ) if yes_pressed: from resources.libs.gui import window window.show_text_box( "Visualizacion de Errores de Instalacion de la Build", error) self.dialogProgress.close() from resources.libs.gui.build_menu import BuildMenu themecount = BuildMenu().theme_count(name) if themecount > 0: self.theme(name) db.addon_database(CONFIG.ADDON_ID, 1) db.force_check_updates(over=True) if os.path.exists(os.path.join(CONFIG.USERDATA, '.enableall')): CONFIG.set_setting('enable_all', 'true') self.dialog.ok( CONFIG.ADDONTITLE, "[COLOR {0}]Para guardar los cambios, ahora necesita Forzar el Cierre de Kodi. \nPresione [B]OK[/B] para Forzar el Cierre de Kodi.[/COLOR]" .format(CONFIG.COLOR2)) tools.kill_kodi(over=True) else: from resources.libs.gui import window window.show_text_box( "Visualizacion de Errores de Instalacion de la Build", error) else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Instalacion Build:[/COLOR] [COLOR gold]Cancelado![/COLOR]' .format(CONFIG.COLOR2))
def build(self, name, over=False): # if action == 'normal': # if CONFIG.KEEPTRAKT == 'true': # from resources.libs import traktit # traktit.auto_update('all') # CONFIG.set_setting('traktnextsave', tools.get_date(days=3, formatted=True)) # if CONFIG.KEEPDEBRID == 'true': # from resources.libs import debridit # debridit.auto_update('all') # CONFIG.set_setting('debridnextsave', tools.get_date(days=3, formatted=True)) # if CONFIG.KEEPLOGIN == 'true': # from resources.libs import loginit # loginit.auto_update('all') # CONFIG.set_setting('loginnextsave', tools.get_date(days=3, formatted=True)) temp_kodiv = int(CONFIG.KODIV) buildv = int(float(check.check_build(name, 'kodi'))) if not temp_kodiv == buildv: warning = True else: warning = False if warning: yes_pressed = self.dialog.yesno( "{0} - [COLOR red]WARNING!![/COLOR]".format(CONFIG.ADDONTITLE), '[COLOR {0}]Existe la posibilidad de que la piel no se vea correctamente' .format(CONFIG.COLOR2) + '\n' + 'Al instalar un {0} build sobre un Kodi {1} Instalar'.format( check.check_build(name, 'kodi'), CONFIG.KODIV) + '\n' + '¿Todavía te gustaría instalar: [COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]' .format(CONFIG.COLOR1, name, check.check_build( name, 'version')), nolabel='[B][COLOR red]No, Cancel[/COLOR][/B]', yeslabel='[B][COLOR springgreen]SI, INSTALAR[/COLOR][/B]') else: if over: yes_pressed = 1 else: yes_pressed = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}]¿Le gustaría descargar e instalar: '.format( CONFIG.COLOR2) + '[COLOR {0}]{1} v{2}[/COLOR]?[/COLOR]'.format( CONFIG.COLOR1, name, check.check_build( name, 'version')), nolabel='[B][COLOR red]No, Cancelar[/COLOR][/B]', yeslabel='[B][COLOR springgreen]si, instalar[/COLOR][/B]') if yes_pressed: CONFIG.clear_setting('build') buildzip = check.check_build(name, 'url') zipname = name.replace('\\', '').replace('/', '').replace( ':', '').replace('*', '').replace('?', '').replace('"', '').replace( '<', '').replace('>', '').replace('|', '') self.dialogProgress.create( CONFIG.ADDONTITLE, '[COLOR {0}][B]descargando:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) + '\n' + 'espere por favor') lib = os.path.join(CONFIG.MYBUILDS, '{0}.zip'.format(zipname)) try: os.remove(lib) except: pass Downloader().download(buildzip, lib) xbmc.sleep(500) if os.path.getsize(lib) == 0: try: os.remove(lib) except: pass return yes_fresh = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}][COLOR {1}]¿Desea borrar todos los datos antes de instalar?[/COLOR]' .format(CONFIG.COLOR2, CONFIG.COLOR1), nolabel='[B][COLOR red]No gracias[/COLOR][/B]', yeslabel='[B][COLOR springgreen]si[/COLOR][/B]') if yes_fresh: install.wipe() skin.look_and_feel_data('save') title = '[COLOR {0}][B]instalando:[/B][/COLOR] [COLOR {1}]{2} v{3}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) self.dialogProgress.update(0, title + '\n' + 'espere por favor') percent, errors, error = extract.all(lib, CONFIG.HOME, title=title) skin.skin_to_default('Build Install') if int(float(percent)) > 0: db.fix_metas() CONFIG.set_setting('buildname', name) CONFIG.set_setting('buildversion', check.check_build(name, 'version')) CONFIG.set_setting('buildtheme', '') CONFIG.set_setting('latestversion', check.check_build(name, 'version')) CONFIG.set_setting( 'nextbuildcheck', tools.get_date(days=CONFIG.UPDATECHECK, formatted=True)) CONFIG.set_setting('installed', 'true') CONFIG.set_setting('extract', percent) CONFIG.set_setting('errors', errors) logging.log('INSTALLED {0}: [ERRORS:{1}]'.format( percent, errors)) try: os.remove(lib) except: pass if int(float(errors)) > 0: yes_pressed = self.dialog.yesno( CONFIG.ADDONTITLE, '[COLOR {0}][COLOR {1}]{2} v{3}[/COLOR]'.format( CONFIG.COLOR2, CONFIG.COLOR1, name, check.check_build(name, 'version')) + '\n' + 'Completado: [COLOR {0}]{1}{2}[/COLOR] [Errors:[COLOR {3}]{4}[/COLOR]]' .format(CONFIG.COLOR1, percent, '%', CONFIG.COLOR1, errors) + '\n' + '¿Le gustaría ver los errores?[/COLOR]', nolabel='[B][COLOR red]No [/COLOR][/B]', yeslabel='[B][COLOR springgreen]si[/COLOR][/B]') if yes_pressed: from resources.libs.gui import window window.show_text_box("Viewing Build Install Errors", error) self.dialogProgress.close() from resources.libs.gui.build_menu import BuildMenu #themecount = BuildMenu().theme_count(name) #if themecount > 0: #self.theme(name, 'theme') db.addon_database(CONFIG.ADDON_ID, 1) #db.force_check_updates(over=True) self.dialog.ok( CONFIG.ADDONTITLE, "[COLOR {0}]Para guardar los cambios, ahora necesita forzar el cierre de Kodi, presione OK para forzar el cierre de Kodi[/COLOR]" .format(CONFIG.COLOR2)) tools.kill_kodi(over=True) else: from resources.libs.gui import window window.show_text_box("Viewing Build Install Errors", error) else: logging.log_notify( CONFIG.ADDONTITLE, '[COLOR {0}]Instalación de compilación: cancelada.[/COLOR]'. format(CONFIG.COLOR2))