def extract_natives(self): if not self.metadata: self.get_meta() natives_tmpdir = os.path.join(self.version_directory, 'natives-' + str(int(time.time()))) ensure_dir(natives_tmpdir) for lib in self.metadata['libraries']: skiplib = False # Check Rules if 'rules' in lib: for rule in lib['rules']: if 'action' in rule: if rule['action'] == 'allow' and 'os' in rule: if not rule['os']['name'] == platform(): skiplib = True if rule['action'] == 'noallow' and 'os' in rule: if rule['os']['name'] == platform(): skiplib = True if skiplib: continue # Skip non-download-included for now if not 'downloads' in lib: continue dl = lib['downloads'] if 'natives' in lib and 'extract' in lib: if platform() in lib['natives']: platform_native = lib['natives'][platform()] if platform_native in dl['classifiers']: try: zip_ref = zipfile.ZipFile( os.path.join( self.client_root, 'libraries', dl['classifiers'][platform_native] ['path']), 'r') zip_ref.extractall(natives_tmpdir) zip_ref.close() except Exception as e: print( 'Failed to extract native library %s due to errors.' % (lib['name'])) raise e metainf = os.path.join(natives_tmpdir, 'META-INF') if os.path.exists(metainf): shutil.rmtree(metainf) self.natives = natives_tmpdir
def PiCCleaner(): myplatform = Common.platform() print "Platform: " + str(myplatform) if not myplatform == 'linux': #Open-/LibreELEC OS *check failed* dialog.ok('XvBMC-Pi-Maintenance', '[COLOR=red][B]!!! NOPE !!![/B][/COLOR]','[US] you\'re running a \'none linux os\' ie. Open-/LibreELEC','[NL] dit is geen Raspberry Pi met Open-/LibreELEC OS...') print "none Linux OS ie. Open-/LibreELEC" # ie. Windows/Mac/Atv else: #Open-/LibreELEC OS *check succes* print "linux os" # ie. Open-/LibreELEC if dialog.yesno('XvBMC-Pi-Maintenance','about to do some extreme CrapCleaner voodoo...','[I]this will take a few seconds to complete, be patient![/I]', '[B]are you sure[COLOR white]?[/COLOR][/B]'): bashCommand = "/bin/bash /storage/.kodi/addons/script.schoonmaak/xvbmc-piecc.sh" os.system(bashCommand) dialog.ok(MainTitle, '[B]Pi[/B] CrapCleaner finished!','', 'Press OK to reboot...') xbmc.executebuiltin("Reboot")
def __init__(self): myplatform=platform() log("XvBMC_Platform: "+str(myplatform)) if not myplatform=='linux': dialog.ok(MainTitle+SubTitle,subtitleNope,nonlinux,nonelecNL) log("none Linux OS ie. Open-/LibreELEC") else: log("linux os") if dialog.yesno("XvBMC-NL Raspberry firmware reset",'RE-Flash XvBMC [COLOR white]\"default\"[/COLOR] firmware?'): bashCommand="/bin/bash /storage/.kodi/addons/script.xvbmc.updatertools/resources/lib/sources/dev/firmwarexvbmc.sh" os.system(bashCommand) dialog.ok(MainTitle,'XvBMC [COLOR white]\"default\"[/COLOR] firmware re-flashed','','Press OK to reboot...') time.sleep(0.5) xbmc.executebuiltin("Reboot")
def PiCCleaner(): myplatform = platform() log("XvBMC_Platform: " + str(myplatform)) if not myplatform == 'linux': dialog.ok(MainTitle + SubTitle, subtitleNope, nonlinux, nonelecNL) log("none Linux OS ie. Open-/LibreELEC") else: log("linux os") if dialog.yesno( MainTitle + SubTitle, 'about to do some extreme CrapCleaner voodoo...', '[I]this will take a few seconds to complete, be patient![/I]', '[B]are you sure[COLOR white]?[/COLOR][/B]'): bashCommand = "/bin/bash /storage/.kodi/addons/script.xvbmc.updatertools/resources/lib/sources/rpiecc.sh" os.system(bashCommand) dialog.ok(MainTitle + SubTitle, '[B]RPi[/B] CrapCleaner finished!', '', 'Press OK to reboot...') xbmc.executebuiltin("Reboot")
def __init__(self): myplatform=platform() log("XvBMC_Platform: "+str(myplatform)) if not myplatform=='linux': dialog.ok(MainTitle+SubTitle,subtitleNope,nonlinux,nonelecNL) log("none Linux OS ie. Open-/LibreELEC") else: log("linux os") if dialog.yesno("XvBMC-NL LibreELEC \'[COLOR white]OS[/COLOR]-update\'",'Preparing OE'+OpenVersie+' and reboot when done...'): url='http://releases.openelec.tv/OpenELEC-RPi2.arm-'+OpenVersie+'.tar' path=xbmc.translatePath(os.path.join('/storage/.update/','')) dp=xbmcgui.DialogProgress() dp.create("XvBMC Nederland","XvBMC-DEV: doing some VoOdOo...",'','Please Wait') lib=os.path.join(path,'openelec'+OpenVersie+'.tar') try: os.remove(lib) except: pass downloader.download(url,lib) time.sleep(3) dialog.ok(MainTitle,'OpenELEC SYSTEM update finished!','','Press OK to reboot...') xbmc.sleep(1000) xbmc.executebuiltin("Reboot")
def launchargs(self): self.library_paths.append( os.path.join(self.version_directory, '%s.jar' % (self.version_name))) gamefmt = { 'version_name': self.version_name, 'game_directory': self.game_dir, 'assets_root': os.path.join(self.client_root, 'assets'), 'assets_index_name': self.metadata['assets'], 'auth_uuid': self.authentication.uuid, 'auth_access_token': self.authentication.access_token, 'user_type': "legacy", 'auth_player_name': self.authentication.player_name, 'version_type': self.metadata['type'] } classpath = ':'.join(self.library_paths) launchclass = self.metadata['mainClass'] # Older arguments if 'minecraftArguments' in self.metadata: launchargs_raw = self.metadata['minecraftArguments'] jvmargs = self.jvm + ' -Djava.library.path=%s -cp %s %s ' % ( self.natives, classpath, launchclass) if 'width' in self.kwargv and 'height' in self.kwargv: launchargs_raw += ' --width %d --height %d ' % ( self.kwargv['width'], self.kwargv['height']) if 'demo' in self.kwargv: launchargs_raw += ' --demo ' gameargs = re.sub(r'\${', '{', launchargs_raw) gameargs = gameargs.format(**gamefmt) return jvmargs + gameargs # New arguments system if 'arguments' in self.metadata: # GAME ARGUMENTS SETUP argconstr = [] for argv in self.metadata['arguments']['game']: if isinstance(argv, dict): if not self.kwargv: continue for rule in argv['rules']: if 'has_custom_resolution' in rule[ 'features'] and 'width' in self.kwargv and 'height' in self.kwargv: argconstr += argv['value'] gamefmt['resolution_width'] = self.kwargv['width'] gamefmt['resolution_height'] = self.kwargv[ 'height'] elif 'is_demo_user' in rule[ 'features'] and 'demo' in self.kwargv: argconstr.append(argv['value']) else: argconstr.append(argv) gameargs = ' '.join(argconstr) gameargs = re.sub(r'\${', '{', gameargs) gameargs = gameargs.format(**gamefmt) # JVM ARGUMENTS SETUP jvargs = self.jvm.split(' ') for x in self.metadata['arguments']['jvm']: if isinstance(x, dict): for rule in argv['rules']: if 'os' in rule and rule['os']['name'] == platform(): if rule['action'] == 'allow': if x['value'] is list: jvargs += x['value'] else: jvargs.append(x['value']) else: jvargs.append(x) jvmargs = ' '.join(jvargs) jvmargs = re.sub(r'\${', '{', jvmargs) jvmargs = jvmargs.format(natives_directory=self.natives, launcher_name='pymclaunch', launcher_version='1.0', classpath=classpath) jvmargs += ' ' + launchclass return jvmargs + ' ' + gameargs
def get_libraries(self): if not self.metadata: self.get_meta() for lib in self.metadata['libraries']: lname = lib['name'].split(':') lurl = lib_url.format(package=lname[0], name=lname[1], version=lname[2]) skiplib = False # Check Rules if 'rules' in lib: for rule in lib['rules']: if 'action' in rule: if rule['action'] == 'allow' and 'os' in rule: if not rule['os']['name'] == platform(): skiplib = True if rule['action'] == 'noallow' and 'os' in rule: if rule['os']['name'] == platform(): skiplib = True if skiplib: continue # Skip non-download-included for now if not 'downloads' in lib: continue dl = lib['downloads'] if 'natives' in lib: if platform() in lib['natives']: platform_native = lib['natives'][platform()] if platform_native in dl['classifiers']: try: self.artifact(dl['classifiers'][platform_native], lname) except Exception as e: print( 'Failed to download native library %s due to errors.' % (lib['name'])) raise e elif 'classifiers' in dl and 'natives-' + platform( ) in dl['classifiers']: self.library_paths.append( os.path.join( os.path.join( self.client_root, 'libraries', dl['classifiers']['natives-' + platform()]['path']))) if not 'artifact' in dl: continue self.library_paths.append( os.path.join( os.path.join(self.client_root, 'libraries', dl['artifact']['path']))) try: self.artifact(dl['artifact'], lname) except Exception as e: print('Failed to download library %s due to errors.' % (lib['name'])) raise e
def autocleannow(): log("AutoCleanNOW") AutoClean = True if os.path.exists(cachePath) == True: for root, dirs, files in os.walk(cachePath): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: if (f.endswith(".log")): continue os.unlink(os.path.join(root, f)) except: pass for d in dirs: try: checker = (os.path.join(root, d)) if not "archive_cache" in str(checker): shutil.rmtree(os.path.join(root, d)) except: pass else: pass if os.path.exists(tempPath) == True: for root, dirs, files in os.walk(tempPath): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: if (f.endswith(".log")): continue os.unlink(os.path.join(root, f)) except: pass for d in dirs: try: checker = (os.path.join(root, d)) if not "archive_cache" in str(checker): shutil.rmtree(os.path.join(root, d)) except: pass else: pass if xbmc.getCondVisibility('system.platform.ATV2'): atv2_cache_a = os.path.join( '/private/var/mobile/Library/Caches/AppleTV/Video/', 'Other') for root, dirs, files in os.walk(atv2_cache_a): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: if (f.endswith(".log")): continue os.unlink(os.path.join(root, f)) except: pass for d in dirs: try: checker = (os.path.join(root, d)) if not "archive_cache" in str(checker): shutil.rmtree(os.path.join(root, d)) except: pass else: pass atv2_cache_b = os.path.join( '/private/var/mobile/Library/Caches/AppleTV/Video/', 'LocalAndRental') for root, dirs, files in os.walk(atv2_cache_b): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: if (f.endswith(".log")): continue os.unlink(os.path.join(root, f)) except: pass for d in dirs: try: checker = (os.path.join(root, d)) if not "archive_cache" in str(checker): shutil.rmtree(os.path.join(root, d)) except: pass else: pass cacheEntries = setupCacheEntries() for entry in cacheEntries: clear_cache_path = xbmc.translatePath(entry.path) if os.path.exists(clear_cache_path) == True: for root, dirs, files in os.walk(clear_cache_path): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: if (f.endswith(".log")): continue os.unlink(os.path.join(root, f)) except: pass for d in dirs: try: checker = (os.path.join(root, d)) if not "archive_cache" in str(checker): shutil.rmtree(os.path.join(root, d)) except: pass else: pass if dialog.yesno( MainTitle, '[COLOR red]This option also deletes all your thumbnails...[/COLOR]', '[COLOR green]Are you sure you want to do this[B]?[/B][/COLOR]'): log("removeThumbs") removeThumbs = True if os.path.exists(thumbnailPath) == True: for root, dirs, files in os.walk(thumbnailPath): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: os.unlink(os.path.join(root, f)) except: pass else: pass else: removeThumbs = False if removeThumbs: text13 = os.path.join(databasePath, "Textures13.db") try: os.unlink(text13) except OSError: myplatform = platform() if myplatform == 'android': Common.log("XvBMC *check* -4- Android") else: Common.log("XvBMC Platform: " + str(myplatform)) try: dbcon = sqlite3.connect(text13) dbcur = dbcon.cursor() dbcur.execute('DROP TABLE IF EXISTS path') dbcur.execute('VACUUM') dbcon.commit() dbcur.execute('DROP TABLE IF EXISTS sizes') dbcur.execute('VACUUM') dbcon.commit() dbcur.execute('DROP TABLE IF EXISTS texture') dbcur.execute('VACUUM') dbcon.commit() dbcur.execute( """CREATE TABLE path (id integer, url text, type text, texture text, primary key(id))""" ) dbcon.commit() dbcur.execute( """CREATE TABLE sizes (idtexture integer,size integer, width integer, height integer, usecount integer, lastusetime text)""" ) dbcon.commit() dbcur.execute( """CREATE TABLE texture (id integer, url text, cachedurl text, imagehash text, lasthashcheck text, PRIMARY KEY(id))""" ) dbcon.commit() except: pass else: Common.log("XvBMC skipped remove thumbnails.") purgePath = xbmc.translatePath('special://home/addons/packages') for root, dirs, files in os.walk(purgePath): file_count = 0 file_count += len(files) for root, dirs, files in os.walk(purgePath): file_count = 0 file_count += len(files) if file_count > 0: try: for f in files: os.unlink(os.path.join(root, f)) for d in dirs: shutil.rmtree(os.path.join(root, d)) except: pass if AutoClean == True: log("AutoCrash") AutoCrash() else: xbmc.log(str(AutoClean)) choice = xbmcgui.Dialog().yesno( MainTitle, '[COLOR white][B]A[/B]uto [B]C[/B]lean finished:[/COLOR]', '[I]cache, crashlogs, packages & thumbnails are removed.[/I]', 'Reboot your device now to finish the process?', yeslabel='[B][COLOR green]YES[/COLOR][/B]', nolabel='[B][COLOR red]NO[/COLOR][/B]') if choice == 1: Common.killKodi()
def deleteThumbnails(): if dialog.yesno("Delete Thumbnails", 'This option deletes all thumbnails', 'Are you sure you want to do this?'): removeThumbs = True if os.path.exists(thumbnailPath) == True: for root, dirs, files in os.walk(thumbnailPath): file_count = 0 file_count += len(files) if file_count > 0: for f in files: try: os.unlink(os.path.join(root, f)) except: pass else: pass else: removeThumbs = False if removeThumbs: text13 = os.path.join(databasePath, "Textures13.db") try: os.unlink(text13) except OSError: myplatform = platform() if myplatform == 'android': Common.log("XvBMC *check* -4- Android") else: Common.log("XvBMC Platform: " + str(myplatform)) try: dbcon = sqlite3.connect(text13) dbcur = dbcon.cursor() dbcur.execute('DROP TABLE IF EXISTS path') dbcur.execute('VACUUM') dbcon.commit() dbcur.execute('DROP TABLE IF EXISTS sizes') dbcur.execute('VACUUM') dbcon.commit() dbcur.execute('DROP TABLE IF EXISTS texture') dbcur.execute('VACUUM') dbcon.commit() dbcur.execute( """CREATE TABLE path (id integer, url text, type text, texture text, primary key(id))""" ) dbcon.commit() dbcur.execute( """CREATE TABLE sizes (idtexture integer,size integer, width integer, height integer, usecount integer, lastusetime text)""" ) dbcon.commit() dbcur.execute( """CREATE TABLE texture (id integer, url text, cachedurl text, imagehash text, lasthashcheck text, PRIMARY KEY(id))""" ) dbcon.commit() except: pass dialog.ok( MainTitle, 'Please [COLOR lime][B]reboot[/B][/COLOR] your system to rebuild thumbnail folder...' ) xbmc.executebuiltin("Container.Refresh") else: dialog.ok(MainTitle, '[COLOR red][B]Skipped:[/B] Delete Thumbnails...[/COLOR]')
except: pass print "Base: "+str(base) print "Mode: "+str(mode) print "URL: "+str(url) print "Name: "+str(name) print "Fanart: "+str(fanart) print "IconImage: "+str(iconimage) if mode==None or url==None or len(url)<1: mainMenu() elif mode==1: # Upgrade(v40) myplatform = Common.platform() print "Platform: " + str(myplatform) if myplatform == 'linux': # Open-/LibreELEC dialog.ok(upgrade40 +' [B]- Pi[/B]', uitgeschakeld +upgrade40 +' '+raspberryPi,'', comingsoon +' image [COLOR dimgray] [B]([/B]Pi 2+3[B])[/B][/COLOR]') # DiSABLE indien v4.0 *online* # #XvbmcPiUpgrade(url) # BLOCKED-4-NOW (v4.0) # else: #rest print "none linux os" dialog.ok(upgrade40 +' - Portable', uitgeschakeld +upgrade40 +' '+Standalonefork,'', comingsoon +' build [COLOR dimgray] [B]([/B]Pi fork[B])[/B][/COLOR]') # DiSABLE indien v4.0 *online* # #XvbmcUpgrade(url) # BLOCKED-4-NOW (v4.0) # elif mode==2: # Upgrade(v31) myplatform = Common.platform() print "Platform: " + str(myplatform) if myplatform == 'linux': # Open-/LibreELEC dialog.ok(upgrade31 +' [B]- Pi[/B]', '[COLOR red]INSTALL: [/COLOR]' +upgrade31 +' '+raspberryPi +' !!!','', comingsoon +' image [COLOR dimgray] [B]([/B]Pi 2+3[B])[/B][/COLOR]') # AANPASSEN in Tip! indien v4.0 *online* #