Exemple #1
0
def transfer_mxci_csv(tfile=None,
                      destiny="SD",
                      cachefolder=None,
                      override=False,
                      keypatch=False,
                      input_files=None):
    check_connection()
    if input_files == None and tfile == None:
        sys.exit("Missing input!!!")
    if destiny == "SD":
        destiny = "1: External SD Card\\"
    if cachefolder == None:
        cachefolder = os.path.join(ztools_dir, '_mtp_cache_')
    if input_files == None:
        input_files = listmanager.read_lines_to_list(tfile, all=True)
    print(f"Creating mxci from {tfile}")
    xciname = gen_mxci_parts(input_files,
                             cachefolder=cachefolder,
                             keypatch=keypatch)
    destinypath = os.path.join(destiny, xciname)
    files_csv = os.path.join(cachefolder, 'files.csv')
    process = subprocess.Popen(
        [nscb_mtp, "TransferfromCSV", "-cs", files_csv, "-dst", destinypath])
    while process.poll() == None:
        if process.poll() != None:
            process.terminate()
    if os.path.exists(cachefolder):
        for f in os.listdir(cachefolder):
            fp = os.path.join(cachefolder, f)
            try:
                shutil.rmtree(fp)
            except OSError:
                os.remove(fp)
Exemple #2
0
def loop_transfer(tfile):
    if not os.path.exists(tfile):
        sys.exit(f"Couldn't find {tfile}")
    destiny = pick_transfer_folder()
    file_list = listmanager.read_lines_to_list(tfile, all=True)
    for item in file_list:
        transfer(filepath=item, destiny=destiny)
        print("")
        listmanager.striplines(tfile, counter=True)
Exemple #3
0
def parsedinstalled():
	installed={}	
	if os.path.exists(games_installed_cache):	
		gamelist=listmanager.read_lines_to_list(games_installed_cache,all=True)	
		for g in gamelist:
			entry=listmanager.parsetags(g)
			entry=list(entry)		
			entry.append(g)
			installed[entry[0]]=entry
	return installed
Exemple #4
0
def loop_install(tfile,destiny="SD",verification=True,outfolder=None,ch_medium=True,check_fw=True,patch_keygen=False,ch_base=False,ch_other=False,install_mode="spec1",st_crypto=False,checked=False):
	check_connection()		
	if not os.path.exists(tfile):
		sys.exit(f"Couldn't find {tfile}")		
	if ch_base==True or ch_other==True:
		if checked==False:		
			print("Content check activated")			
			retrieve_installed()
			installed=parsedinstalled()
		elif checked==True:	
			print("Content check activated. Games are preparsed")		
			installed=parsedinstalled()	
	file_list=listmanager.read_lines_to_list(tfile,all=True)
	for item in file_list:
		try:
			if ch_base==True or ch_other==True:
				fileid,fileversion,cctag,nG,nU,nD,baseid=listmanager.parsetags(item)
				if fileid.endswith('000') and fileversion==0 and fileid in installed.keys() and ch_base==True:
					print("Base game already installed. Skipping...")
					listmanager.striplines(tfile,counter=True)
					continue
				elif fileid.endswith('000') and fileid in installed.keys() and ch_other==True:
					updid=fileid[:-3]+'800'
					if fileversion>((installed[fileid])[2]):
						print("Asking DBI to delete previous content")
						process=subprocess.Popen([nscb_mtp,"DeleteID","-ID",fileid])	
						while process.poll()==None:
							if process.poll()!=None:
								process.terminate();					
						process=subprocess.Popen([nscb_mtp,"DeleteID","-ID",updid])		
						while process.poll()==None:
							if process.poll()!=None:
								process.terminate();					
					else:
						print("The update is a previous version than the installed on device.Skipping..")
						listmanager.striplines(tfile,counter=True)
						continue				
				elif ch_other==True	and fileid in installed.keys():
					if fileversion>((installed[fileid])[2]):
						print("Asking DBI to delete previous update")
						process=subprocess.Popen([nscb_mtp,"DeleteID","-ID",fileid])					
						while process.poll()==None:
							if process.poll()!=None:
								process.terminate();
					else:
						print("The update is a previous version than the installed on device.Skipping..")
						listmanager.striplines(tfile,counter=True)
						continue	
		except:pass				
		install(filepath=item,destiny=destiny,verification=verification,outfolder=outfolder,ch_medium=ch_medium,check_fw=check_fw,patch_keygen=patch_keygen,install_mode=install_mode,st_crypto=st_crypto)
		print("")
		listmanager.striplines(tfile,counter=True)
Exemple #5
0
def loop_xci_transfer(tfile,destiny=False,verification=True,outfolder=None,patch_keygen=False,mode="single"):
	if destiny==False or destiny=="pick" or destiny=="":
		destiny=pick_transfer_folder()	
	if not os.path.exists(tfile):
		sys.exit(f"Couldn't find {tfile}")	
	file_list=listmanager.read_lines_to_list(tfile,all=True)
	for item in file_list:
		if mode=="single":
			generate_xci_and_transfer(filepath=item,destiny=destiny,verification=verification,outfolder=outfolder,kgpatch=patch_keygen)
			print("")
			listmanager.striplines(tfile,counter=True)
		elif mode=="multi":
			continue
Exemple #6
0
def parsedinstalled(exclude_xci=True):
    installed = {}
    if os.path.exists(games_installed_cache):
        gamelist = listmanager.read_lines_to_list(games_installed_cache,
                                                  all=True)
        for g in gamelist:
            if exclude_xci == True:
                if g.endswith('xci') or g.endswith('xc0'):
                    continue
            entry = listmanager.parsetags(g)
            entry = list(entry)
            entry.append(g)
            installed[entry[0]] = entry
    return installed
Exemple #7
0
def rename_nsx(fp):
    if fp.endswith('.txt'):
        filelist = listmanager.read_lines_to_list(fp, all=True)
        for file in filelist:
            if file[0] == '"':
                file = file[1:]
            if file[-1] == '"':
                file = file[:-1]
            file = os.path.abspath(file)
            test_ifnsx(file)
            listmanager.striplines(fp, number=1, counter=True)
    else:
        test_ifnsx(fp)
    try:
        os.remove(fp)
    except:
        pass
def loop_install(tfile,destiny="SD",outfolder=None,ch_medium=True,check_fw=True,patch_keygen=False,ch_base=False,ch_other=False,truecopy=True,checked=False):	
	check_connection()
	if not os.path.exists(tfile):
		sys.exit(f"Couldn't find {tfile}")	
	from mtpinstaller import retrieve_installed,parsedinstalled
	installed=[]
	if ch_base==True or ch_other==True:
		if checked==False:		
			print("Content check activated")			
			retrieve_installed()
			installed=parsedinstalled()		
		elif checked==True:
			print("Content check activated. Games are preparsed")		
			installed=parsedinstalled()		
	file_list=listmanager.read_lines_to_list(tfile,all=True)	
	for item in file_list:
		if item.startswith('https://1fichier.com'):
			print("Item is 1fichier link. Redirecting...")
			fichier_install(item,destiny,ch_medium,ch_base=ch_base,ch_other=ch_other,installed_list=installed)			
		elif item.startswith('https://drive.google.com'):
			print("Item is google drive public link. Redirecting...")
			public_gdrive_install(item,destiny,outfolder=outfolder,ch_medium=ch_medium,check_fw=check_fw,patch_keygen=patch_keygen,ch_base=ch_base,ch_other=ch_other,checked=checked,truecopy=truecopy,installed_list=installed)			
		elif os.path.exists(item):
			print("Item is a local link. Skipping...")	
		else:
			try:
				test=item.split('|')
				if len(test)<2:
					item=test[0]
					lib,TD,libpath=get_library_from_path(remote_lib_file,item)			
					if lib!=None:
						print("Item is a remote library link. Redirecting...")
						gdrive_install(item,destiny,outfolder=outfolder,ch_medium=ch_medium,check_fw=check_fw,patch_keygen=patch_keygen,ch_base=ch_base,ch_other=ch_other,checked=checked,installed_list=installed)
					else:
						print("Couldn't find file. Skipping...")					
				else:	
					gdrive_install(item,destiny,outfolder=outfolder,ch_medium=ch_medium,check_fw=check_fw,patch_keygen=patch_keygen,ch_base=ch_base,ch_other=ch_other,checked=checked,installed_list=installed)	
			except BaseException as e:
				Print.error('Exception: ' + str(e))
				print(f"Couldn't find {test[0]}. Skipping...")
		print("")					
		listmanager.striplines(tfile,1,True)						
def loop_transfer(tfile):	
	check_connection()
	if not os.path.exists(tfile):
		sys.exit(f"Couldn't find {tfile}")		
	from mtp_game_manager import pick_transfer_folder
	destiny=pick_transfer_folder()
	file_list=listmanager.read_lines_to_list(tfile,all=True)	
	for item in file_list:
		if item.startswith('https://1fichier.com'):
			print("Item is 1fichier link. Redirecting...")
			fichier_transfer(item,destiny)			
		elif item.startswith('https://drive.google.com'):
			print("Item is google drive public link. Redirecting...")
			public_gdrive_transfer(item,destiny)			
		elif os.path.exists(item):
			print("Item is a local link. Skipping...")	
		else:
			test=item.split('|')
			item=test[0]
			lib,TD,libpath=get_library_from_path(remote_lib_file,item)			
			if lib!=None:
				print("Item is a remote library link. Redirecting...")
				gdrive_transfer(item,destiny)
		print("")		
Exemple #10
0
def check_xci_certs(ifolder, tfile, tfile2):
    from listmanager import folder_to_list, striplines, read_lines_to_list
    from Fs import Xci
    import os
    if not os.path.exists(tfile):
        xci_files = folder_to_list(ifolder, ['xci'])
        with open(tfile, "w", encoding='utf8') as t:
            for file in xci_files:
                t.write(file + '\n')
    else:
        xci_files = read_lines_to_list(tfile, all=True)
    counter = len(xci_files)
    for file in xci_files:
        try:
            xci = Xci(file)
            if not xci.gamecardCert.Cert_is_fake:
                print(f"{file} has personalized certificate")
                with open(tfile2, "a", encoding='utf8') as t:
                    t.write(file + '\n')
            else:
                print(f"{file} has a wiped certificate")
            xci.close()
            counter -= 1
            striplines(tfile, 1, True)
        except:
            try:
                with open(tfile2, "a", encoding='utf8') as t:
                    t.write("Error:" + file + '\n')
            except:
                pass
            counter -= 1
            striplines(tfile, 1, True)
    try:
        os.remove(tfile)
    except:
        pass
Exemple #11
0
def pararell(args, workers):
    from subprocess import call
    from time import sleep
    c = 0
    workers = int(workers)
    tfile = args.text_file
    args0 = args
    f = False
    filelist = listmanager.read_lines_to_list(tfile, all=True)
    if not args.findfile:
        items = listmanager.counter(args.text_file)
        index = 0
        process = list()
        while items != 0:
            if c == 0:
                c += 1
            else:
                #print("")
                pass

            from colorama import Fore
            colors = Fore.__dict__
            p = 0
            for r in range(workers):
                if index != items:
                    k = 0
                    l = p
                    for col in colors:
                        if l > len(colors):
                            l = l - len(colors)
                        color = colors[col]
                        if k == (l + 1):
                            break
                        else:
                            k += 1
                    #listmanager.printcurrent(tfile)
                    try:
                        f = filelist[index]
                    except:
                        break
                    tq = tqdm(leave=False, position=0)
                    #tq = tqdm(leave=False,position=0,bar_format="{l_bar}%s{bar}%s{r_bar}" % (color, color))
                    tq.write('Opening thread for ' + f)
                    tq.close()
                    tq = tqdm(total=1,
                              unit='|',
                              leave=True,
                              position=0,
                              bar_format="{l_bar}%s{bar}%s{r_bar}" %
                              (color, Fore.RESET))
                    tq.update(1)
                    tq.close()
                    opworkers = workers
                    if items < workers:
                        opworkers = items
                    arguments, nonevar = getargs(args,
                                                 separate_list=False,
                                                 current=f,
                                                 pos=p,
                                                 tothreads=opworkers)
                    #print(arguments)
                    f = False
                    args = args0
                    #print(arguments)
                    process.append(subprocess.Popen(arguments))
                    index += 1
                    p += 1

            for pr in process:
                #pr.wait()
                #call('clear' if os.name =='posix' else 'cls')
                # print(str(p.poll()))
                while pr.poll() == None:
                    sleep(3)
                    if os.name == 'posix':
                        call('clear')  #linux
                    else:
                        try:
                            call('cls')  #macos
                        except:
                            print("\n" * 100)
                            os.system('cls')  #windows
                    listmanager.counter(tfile, doprint=True)
                    p = 0
                    index2 = index - workers
                    for r in range(workers):
                        if index2 != items:
                            k = 0
                            l = p
                            for col in colors:
                                if l > len(colors):
                                    l = l - len(colors)
                                color = colors[col]
                                if k == (l + 1):
                                    break
                                else:
                                    k += 1
                            #listmanager.printcurrent(tfile)
                            try:
                                f = filelist[index2]
                            except:
                                break
                            tq = tqdm(leave=False, position=0)
                            # tq = tqdm(leave=False,position=0,bar_format="{l_bar}%s{bar}%s{r_bar}" % (color, color))
                            tq.write('Opening thread for ' + f)
                            tq.close()
                            tq = tqdm(total=1,
                                      unit='|',
                                      leave=True,
                                      position=0,
                                      bar_format="{l_bar}%s{bar}%s{r_bar}" %
                                      (color, Fore.RESET))
                            tq.update(1)
                            tq.close()
                            index2 += 1
                            p += 1
                    if pr.poll() != None:
                        pr.terminate()
            if os.name == 'posix':
                call('clear')  #linux
            else:
                try:
                    call('cls')  #macos
                except:
                    os.system('cls')  #windows
            listmanager.striplines(tfile, number=workers, counter=False)
            items -= workers
            if items < 0:
                items = 0
        return items
Exemple #12
0
def update_console(libraries="all",
                   destiny="SD",
                   exclude_xci=True,
                   prioritize_nsz=True,
                   tfile=None,
                   verification=True,
                   ch_medium=True,
                   ch_other=False,
                   autoupd_aut=True):
    if tfile == None:
        tfile = os.path.join(NSCB_dir, 'MTP1.txt')
    if os.path.exists(tfile):
        try:
            os.remove(tfile)
        except:
            pass
    libdict = get_libs("source")
    pths = {}
    if libraries == "all":
        for entry in libdict.keys():
            pths[entry] = ((libdict[entry])[0])
    else:
        for entry in libdict.keys():
            if (libdict[entry])[1] == True:
                pths[entry] = ((libdict[entry])[0])
    if not os.path.exists(cachefolder):
        os.makedirs(cachefolder)
    for f in os.listdir(cachefolder):
        fp = os.path.join(cachefolder, f)
        try:
            shutil.rmtree(fp)
        except OSError:
            os.remove(fp)
    print("1. Parsing games in device. Please Wait...")
    process = subprocess.Popen([
        nscb_mtp, "ShowInstalled", "-tfile", games_installed_cache, "-show",
        "false"
    ],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    while process.poll() == None:
        if process.poll() != None:
            process.terminate()
    if os.path.exists(games_installed_cache):
        print("   Success")
    gamelist = listmanager.read_lines_to_list(games_installed_cache, all=True)
    installed = {}
    for g in gamelist:
        if exclude_xci == True:
            if g.endswith('xci') or g.endswith('xc0'):
                continue
        entry = listmanager.parsetags(g)
        entry = list(entry)
        entry.append(g)
        installed[entry[0]] = entry
    print("2. Parsing local libraries. Please Wait...")
    locallist = []
    for p in pths.keys():
        locallist += listmanager.folder_to_list(pths[p], ['nsp', 'nsz'])
        print(f'   Parsed Library: "{str(p).upper()}"')
    if prioritize_nsz == True:
        locallist = sorted(locallist, key=lambda x: x[-1])
        locallist.reverse()
    localgames = {}
    for g in locallist:
        entry = listmanager.parsetags(g)
        entry = list(entry)
        entry.append(g)
        if not entry[0] in localgames:
            localgames[entry[0]] = entry
        else:
            v = (localgames[entry[0]])[1]
            if int(entry[1]) > int(v):
                localgames[entry[0]] = entry
    print("3. Searching new updates. Please Wait...")
    gamestosend = {}
    for g in installed.keys():
        if g.endswith('000') or g.endswith('800'):
            try:
                updid = g[:-3] + '800'
                if updid in localgames:
                    if updid in installed:
                        if ((installed[updid])[1]) < ((localgames[updid])[1]):
                            if not updid in gamestosend:
                                gamestosend[updid] = localgames[updid]
                            else:
                                if ((gamestosend[updid])[1]) < (
                                    (localgames[updid])[1]):
                                    gamestosend[updid] = localgames[updid]
                    else:
                        if not updid in gamestosend:
                            gamestosend[updid] = localgames[updid]
                        else:
                            if ((gamestosend[updid])[1]) < (
                                (localgames[updid])[1]):
                                gamestosend[updid] = localgames[updid]
            except:
                pass
        else:
            try:
                if g in localgames:
                    if ((installed[g])[1]) < ((localgames[g])[1]):
                        if not g in gamestosend:
                            gamestosend[g] = localgames[g]
                        else:
                            if ((gamestosend[g])[1]) < ((localgames[g])[1]):
                                gamestosend[g] = localgames[g]
            except:
                pass
    print("4. Searching new dlcs. Please Wait...")
    for g in installed.keys():
        try:
            if g.endswith('000') or g.endswith('800'):
                baseid = g[:-3] + '000'
            else:
                baseid = (installed[g])[6]
            for k in localgames.keys():
                try:
                    if not (k.endswith('000')
                            or k.endswith('800')) and not k in installed:
                        test = get_dlc_baseid(k)
                        if baseid == test:
                            if not k in gamestosend:
                                gamestosend[k] = localgames[k]
                            else:
                                if ((gamestosend[k])[1]) < (
                                    (localgames[k])[1]):
                                    gamestosend[k] = localgames[k]
                except BaseException as e:
                    # Print.error('Exception: ' + str(e))
                    pass
        except BaseException as e:
            # Print.error('Exception: ' + str(e))
            pass
    print("5. List of content that will get installed...")
    gamepaths = []
    if len(gamestosend.keys()) > 0:
        if autoupd_aut == True:
            for i in sorted(gamestosend.keys()):
                fileid, fileversion, cctag, nG, nU, nD, baseid, path = gamestosend[
                    i]
                bname = os.path.basename(path)
                gamepaths.append(path)
                g0 = [pos for pos, char in enumerate(bname) if char == '[']
                g0 = (bname[0:g0[0]]).strip()
                print(
                    f"   * {g0} [{fileid}][{fileversion}] [{cctag}] - {(bname[-3:]).upper()}"
                )
        else:
            options = []
            for i in sorted(gamestosend.keys()):
                fileid, fileversion, cctag, nG, nU, nD, baseid, path = gamestosend[
                    i]
                bname = os.path.basename(path)
                gamepaths.append(path)
                g0 = [pos for pos, char in enumerate(bname) if char == '[']
                g0 = (bname[0:g0[0]]).strip()
                cstring = f"{g0} [{fileid}][{fileversion}] [{cctag}] - {(bname[-3:]).upper()}"
                options.append(cstring)
            if options:
                title = 'Select content to install: \n + Press space or right to select entries \n + Press E to finish selection \n + Press A to select all entries'
                picker = Picker(options,
                                title,
                                multi_select=True,
                                min_selection_count=1)

                def end_selection(picker):
                    return False, -1

                def select_all(picker):
                    return "ALL", -1

                picker.register_custom_handler(ord('e'), end_selection)
                picker.register_custom_handler(ord('E'), end_selection)
                picker.register_custom_handler(ord('a'), select_all)
                picker.register_custom_handler(ord('A'), select_all)
                selected = picker.start()
                if selected[0] == False:
                    print("    User didn't select any files")
                    return False
                if selected[0] == "ALL":
                    pass
                else:
                    newgpaths = []
                    for game in selected:
                        g = game[1]
                        g0 = gamepaths[g]
                        newgpaths.append(g0)
                    gamepaths = newgpaths
        print("6. Generating text file...")
        with open(tfile, 'w', encoding='utf8') as textfile:
            for i in gamepaths:
                textfile.write((i).strip() + "\n")
        print("7. Triggering installer on loop mode.")
        print(
            "   Note:If you interrupt the list use normal install mode to continue list"
        )
        loop_install(tfile,
                     destiny=destiny,
                     verification=verification,
                     ch_medium=ch_medium,
                     ch_other=ch_other,
                     checked=True)
    else:
        print("\n   --- DEVICE IS UP TO DATE ---")
Exemple #13
0
def route(args, workers):
    arguments, tfile = getargs(args)
    #print(arguments)
    # print(tfile)
    if tfile == False:
        process = subprocess.Popen(arguments)
        while process.poll() == None and process2.poll() == None:
            if process.poll() != None:
                process.terminate()
            if process2.poll() != None:
                process2.terminate()
        #op,oe=process.communicate();#print (op);print (oe)
        #process.terminate();process2.terminate()
    else:
        filelist = listmanager.read_lines_to_list(tfile, number=workers)
        commands = list()
        i = 0
        #print(filelist)
        for allw in allowedlist:
            if allw in arguments:
                ind = arguments.index(allw)
                ind += 1
                break
        ind2 = False
        try:
            ind2 = arguments.index('--db_file')
            ind2 += 1
            sub_r = arguments[ind2]
        except:
            pass
        process = list()
        sub_r = arguments[ind2]
        c = 0
        if ind2 != False:
            if not os.path.isdir(sub_r) and not str(sub_r).endswith(
                    'all_DB.txt'):
                folder = os.path.dirname(os.path.abspath(sub_r))
                ruta = os.path.abspath(os.path.join(folder, "temp"))
            else:
                folder = os.path.dirname(os.path.abspath(sub_r))
                ruta = os.path.abspath(os.path.join(folder, "temp"))
            if not os.path.exists(ruta):
                os.makedirs(ruta)
        for f in filelist:
            arguments[ind] = f
            #print (arguments)
            if ind2 != False:
                if not os.path.isdir(sub_r) and not str(sub_r).endswith(
                        'all_DB.txt'):
                    fi = str(os.path.basename(
                        os.path.abspath(sub_r))) + '_' + str(c)
                    ruta2 = os.path.abspath(os.path.join(ruta, fi))
                    arguments[ind2] = ruta2
                    #print(ruta2)
                else:
                    ruta2 = os.path.abspath(os.path.join(ruta, str(c)))
                    if not os.path.exists(ruta2):
                        os.makedirs(ruta2)
                    fi = os.path.join(ruta2, 'all_DB.txt')
                    arguments[ind2] = fi
                    #print(arguments)
                c += 1
            process.append(subprocess.Popen(arguments))
            #print(process)
            #print(f)
        #print(len(process))
        for p in process:
            p.wait()
            # print(str(p.poll()))
            while p.poll() == None:
                if p.poll() != None:
                    p.terminate()

        if ind2 != False:
            if not os.path.isdir(sub_r) and not str(sub_r).endswith(
                    'all_DB.txt'):
                for i in range(int(workers - 1)):
                    fi = str(os.path.basename(
                        os.path.abspath(sub_r))) + '_' + str(i)
                    t = os.path.join(ruta, fi)
                    if os.path.exists(t):
                        with open(t, "r+", encoding='utf8') as filelist:
                            if not os.path.exists(sub_r):
                                with open(sub_r, "w", encoding='utf8') as dbt:
                                    for line in filelist:
                                        dbt.write(line)
                            else:
                                c = 0
                                with open(sub_r, "a", encoding='utf8') as dbt:
                                    for line in filelist:
                                        if not c == 0:
                                            dbt.write(line)
                                        c += 1
                    i += 1
                try:
                    os.remove(ruta)
                except BaseException as e:
                    Print.error('Exception: ' + str(e))
                    pass
            else:
                include = [
                    'extended_DB.txt', 'nutdb_DB.txt', 'keyless_DB.txt',
                    'simple_DB.txt'
                ]
                for i in range(int(workers - 1)):
                    for input in include:
                        ruta2 = os.path.abspath(os.path.join(ruta, str(i)))
                        t = os.path.join(ruta2, input)
                        t2 = os.path.join(folder, input)
                        # print(t)
                        # print(t2)
                        if os.path.exists(t):
                            with open(t, "r+", encoding='utf8') as filelist:
                                if not os.path.exists(t2):
                                    with open(t2, "w", encoding='utf8') as dbt:
                                        for line in filelist:
                                            dbt.write(line)
                                else:
                                    c = 0
                                    with open(t2, "a", encoding='utf8') as dbt:
                                        for line in filelist:
                                            if not c == 0:
                                                dbt.write(line)
                                            c += 1
                        i += 1
                    try:
                        os.remove(t)
                    except:
                        pass
                    try:
                        os.remove(ruta2)
                    except:
                        pass
        try:
            os.remove(ruta)
        except:
            pass

        listmanager.striplines(tfile, number=workers, counter=True)
Exemple #14
0
def get_archived_info(search_new=True, excludehb=True):
    forecombo = Style.BRIGHT + Back.GREEN + Fore.WHITE
    if not os.path.exists(cachefolder):
        os.makedirs(cachefolder)
    for f in os.listdir(cachefolder):
        fp = os.path.join(cachefolder, f)
        try:
            shutil.rmtree(fp)
        except OSError:
            os.remove(fp)
    print("1. Retrieving registered...")
    dbicsv = os.path.join(cachefolder, "registered.csv")
    process = subprocess.Popen([
        nscb_mtp, "Download", "-ori",
        "4: Installed games\\InstalledApplications.csv", "-dst", dbicsv
    ],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    while process.poll() == None:
        if process.poll() != None:
            process.terminate()
    if os.path.exists(dbicsv):
        print("   Success")
    print("2. Checking Installed...")
    process = subprocess.Popen([
        nscb_mtp, "ShowInstalled", "-tfile", games_installed_cache, "-show",
        "false"
    ],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
    while process.poll() == None:
        if process.poll() != None:
            process.terminate()
    if os.path.exists(games_installed_cache):
        print("   Success")
    gamelist = listmanager.read_lines_to_list(games_installed_cache, all=True)
    dbi_dict = {}
    with open(dbicsv, 'rt', encoding='utf8') as csvfile:
        readCSV = csv.reader(csvfile, delimiter=',')
        id = 0
        ver = 1
        tname = 2
        for row in readCSV:
            try:
                tid = (str(row[id]).upper())[2:]
                version = int(row[ver])
                name = str(row[tname])
                dbi_dict[tid] = [tid, version, name]
            except:
                pass
    installed = {}
    for g in gamelist:
        entry = listmanager.parsetags(g)
        installed[entry[0]] = entry
    print("..........................................................")
    print("ARCHIVED|REGISTERED GAMES")
    print("..........................................................")
    for g in dbi_dict.keys():
        if not g in installed.keys():
            tid, version, name = dbi_dict[g]
            if len(name) > 33:
                name = name[0:30] + '...'
            print(f"{name} [{tid}][{version}]")
    if search_new == True:
        import nutdb
        nutdb.check_other_file(urlconfig, 'versions_txt')
        f = 'nutdb_' + 'versions' + '.txt'
        DATABASE_folder = nutdb.get_DBfolder()
        _dbfile_ = os.path.join(DATABASE_folder, f)
        versiondict = {}
        with open(_dbfile_, 'rt', encoding='utf8') as csvfile:
            readCSV = csv.reader(csvfile, delimiter='|')
            i = 0
            for row in readCSV:
                if i == 0:
                    csvheader = row
                    i = 1
                    if 'id' and 'version' in csvheader:
                        id = csvheader.index('id')
                        ver = csvheader.index('version')
                    else:
                        break
                else:
                    try:
                        tid = str(row[id]).upper()
                        version = str(row[ver]).upper()
                        if tid.endswith('800'):
                            baseid = tid[:-3] + '000'
                        if baseid in versiondict.keys():
                            v = versiondict[baseid]
                            if v < int(version):
                                versiondict[baseid] = int(version)
                        else:
                            versiondict[tid] = int(version)
                    except:
                        pass
        print("..........................................................")
        print("NEW UPDATES")
        print("..........................................................")
        for k in dbi_dict.keys():
            fileid, fileversion, g0 = dbi_dict[k]
            if len(g0) > 33:
                g0 = g0[0:30] + '...'
            else:
                g0 = g0 + (33 - len(g0)) * ' '
            v = 0
            updateid = fileid[:-3] + '800'
            if updateid in dbi_dict.keys() and fileid.endswith('000'):
                continue
            if fileid.endswith('800'):
                try:
                    v = versiondict[baseid]
                except:
                    pass
            else:
                try:
                    v = versiondict[fileid]
                except:
                    pass
            if int(v) > int(fileversion):
                if fileid.endswith('000') or fileid.endswith('800'):
                    updid = fileid[:-3] + '800'
                    print(f"{g0} [{baseid}][{fileversion}] -> " + forecombo +
                          f"[{updid}] [v{v}]" + Style.RESET_ALL)
                else:
                    print(f"{g0} [{fileid}][{fileversion}] -> " + forecombo +
                          f"[{fileid}] [v{v}]" + Style.RESET_ALL)
        print("..........................................................")
        print("NEW DLCS")
        print("..........................................................")
        for k in versiondict.keys():
            if k in dbi_dict.keys() or k.endswith('000') or k.endswith('800'):
                continue
            else:
                baseid = get_dlc_baseid(k)
                updid = baseid[:-3] + '800'
                if baseid in dbi_dict.keys() or updid in dbi_dict.keys():
                    fileid, fileversion, g0 = dbi_dict[baseid]
                    if len(g0) > 33:
                        g0 = g0[0:30] + '...'
                    else:
                        g0 = g0 + ((33 - len(g0)) * ' ')
                    print(f"{g0} [{baseid}] -> " + forecombo +
                          f"[{k}] [v{versiondict[k]}]" + Style.RESET_ALL)
Exemple #15
0
def get_installed_info(tfile=None, search_new=True, excludehb=True):
    if not os.path.exists(cachefolder):
        os.makedirs(cachefolder)
    forecombo = Style.BRIGHT + Back.GREEN + Fore.WHITE
    if tfile == "":
        tfile = None
    if os.path.exists(games_installed_cache):
        try:
            os.remove(games_installed_cache)
        except:
            pass
    if tfile == None:
        for f in os.listdir(cachefolder):
            fp = os.path.join(cachefolder, f)
            try:
                shutil.rmtree(fp)
            except OSError:
                os.remove(fp)
        process = subprocess.Popen([
            nscb_mtp, "ShowInstalled", "-tfile", games_installed_cache,
            "-show", "false"
        ],
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
        print("Parsing games in device. Please Wait...")
        while process.poll() == None:
            if process.poll() != None:
                process.terminate()
    if os.path.exists(games_installed_cache):
        gamelist = listmanager.read_lines_to_list(games_installed_cache,
                                                  all=True)
        gamelist.sort()
        print("..........................................................")
        print("CONTENT FOUND ON DEVICE")
        print("..........................................................")
        installed = {}
        for g in gamelist:
            fileid, fileversion, cctag, nG, nU, nD, baseid = listmanager.parsetags(
                g)
            g0 = [pos for pos, char in enumerate(g) if char == '[']
            g0 = (g[0:g0[0]]).strip()
            installed[fileid] = [
                fileid, fileversion, cctag, nG, nU, nD, baseid, g0, g
            ]
            if len(g0) > 33:
                g0 = g0[0:30] + '...'
            else:
                g0 = g0 + ((33 - len(g0)) * ' ')
            verprint = str(fileversion)
            if len(verprint) < 9:
                verprint = verprint + ((9 - len(verprint)) * ' ')
            if excludehb == True:
                if not fileid.startswith('05') and not fileid.startswith(
                        '04') and not str(fileid).lower() == 'unknown':
                    if g.endswith('.xci') or g.endswith('.xc0'):
                        print(
                            f"{g0}|{fileid}|{verprint}|XCI|{nG}G|{nU}U|{nD}D")
                    else:
                        print(f"{g0}|{fileid}|{verprint}|{cctag}")
            else:
                if g.endswith('.xci') or g.endswith('.xc0'):
                    print(f"{g0}|{fileid}|{verprint}|XCI|{nG}G|{nU}U|{nD}D")
                else:
                    print(f"{g0}|{fileid}|{verprint}|{cctag}")
        if search_new == True:
            import nutdb
            nutdb.check_other_file(urlconfig, 'versions_txt')
            f = 'nutdb_' + 'versions' + '.txt'
            DATABASE_folder = nutdb.get_DBfolder()
            _dbfile_ = os.path.join(DATABASE_folder, f)
            versiondict = {}
            with open(_dbfile_, 'rt', encoding='utf8') as csvfile:
                readCSV = csv.reader(csvfile, delimiter='|')
                i = 0
                for row in readCSV:
                    if i == 0:
                        csvheader = row
                        i = 1
                        if 'id' and 'version' in csvheader:
                            id = csvheader.index('id')
                            ver = csvheader.index('version')
                        else:
                            break
                    else:
                        try:
                            tid = str(row[id]).upper()
                            version = str(row[ver]).upper()
                            if tid.endswith('800'):
                                baseid = tid[:-3] + '000'
                            if baseid in versiondict.keys():
                                v = versiondict[baseid]
                                if v < int(version):
                                    versiondict[baseid] = int(version)
                            else:
                                versiondict[tid] = int(version)
                        except:
                            pass
            print("..........................................................")
            print("NEW UPDATES")
            print("..........................................................")
            for k in installed.keys():
                fileid, fileversion, cctag, nG, nU, nD, baseid, g0, g = installed[
                    k]
                if len(g0) > 33:
                    g0 = g0[0:30] + '...'
                else:
                    g0 = g0 + ((33 - len(g0)) * ' ')
                verprint = str(fileversion)
                fillver = ''
                if len(verprint) < 6:
                    fillver = (6 - len(verprint)) * ' '
                v = 0
                updateid = fileid[:-3] + '800'
                if updateid in installed.keys() and fileid.endswith('000'):
                    continue
                if fileid.endswith('800'):
                    try:
                        v = versiondict[baseid]
                    except:
                        pass
                else:
                    try:
                        v = versiondict[fileid]
                    except:
                        pass
                if int(v) > int(fileversion):
                    if fileid.endswith('000') or fileid.endswith('800'):
                        updid = fileid[:-3] + '800'
                        print(f"{g0} [{baseid}][{verprint}]{fillver} -> " +
                              forecombo + f"[{updid}] [v{v}]" +
                              Style.RESET_ALL)
                    else:
                        print(f"{g0} [{fileid}][{verprint}]{fillver} -> " +
                              forecombo + f"[{fileid}] [v{v}]" +
                              Style.RESET_ALL)
            check_xcis = False
            xci_dlcs = {}
            print("..........................................................")
            print("NEW DLCS")
            print("..........................................................")
            for k in versiondict.keys():
                if k in installed.keys() or k.endswith('000') or k.endswith(
                        '800'):
                    continue
                else:
                    baseid = get_dlc_baseid(k)
                    updid = baseid[:-3] + '800'
                    if baseid in installed.keys() or updid in installed.keys():
                        fileid, fileversion, cctag, nG, nU, nD, baseid, g0, g = installed[
                            baseid]
                        if nD > 0:
                            if check_xcis == False:
                                check_xcis = True
                            if not baseid in xci_dlcs.keys():
                                entry = list()
                                entry.append(k)
                                xci_dlcs[baseid] = entry
                            else:
                                entry = xci_dlcs[baseid]
                                entry.append(k)
                                xci_dlcs[baseid] = entry
                            continue
                        if len(g0) > 33:
                            g0 = g0[0:30] + '...'
                        else:
                            g0 = g0 + ((33 - len(g0)) * ' ')
                        print(f"{g0} [{baseid}] -> " + forecombo +
                              f"[{k}] [v{versiondict[k]}]" + Style.RESET_ALL)
            t = 0
            if check_xcis == True:
                for bid in xci_dlcs.keys():
                    fileid, fileversion, cctag, nG, nU, nD, baseid, g0, g = installed[
                        bid]
                    entry = xci_dlcs[bid]
                    test = len(entry)
                    if test > nD:
                        if t == 0:
                            print(
                                ".........................................................."
                            )
                            print("XCI MAY HAVE NEW DLCS. LISTING AVAILABLE")
                            print(
                                ".........................................................."
                            )
                            t += 1
                        if len(g0) > 33:
                            g0 = g0[0:30] + '...'
                        else:
                            g0 = g0 + ((33 - len(g0)) * ' ')
                        for k in xci_dlcs[baseid]:
                            print(f"{g0} [{baseid}] -> " + forecombo +
                                  f"[{k}] [v{versiondict[k]}]" +
                                  Style.RESET_ALL)
def update_console_from_gd(libraries="all",destiny="SD",exclude_xci=True,prioritize_nsz=True,tfile=None,verification=True,ch_medium=True,ch_other=False,autoupd_aut=True,use_archived=False):	
	check_connection()
	if use_archived==True:
		autoupd_aut=False	
	if tfile==None:
		tfile=os.path.join(NSCB_dir, 'MTP1.txt')
	if os.path.exists(tfile):
		try:
			os.remove(tfile)
		except: pass			
	libdict=get_libs_remote_source(remote_lib_file);
	if libdict==False:
		sys.exit("No libraries set up")
	pths={};TDs={};
	if libraries=="all":
		for entry in libdict.keys():
			pths[entry]=((libdict[entry])[0])
			TDs[entry]=((libdict[entry])[1])
	else:
		for entry in libdict.keys():
			if (libdict[entry])[2]==True:
				pths[entry]=((libdict[entry])[0])	
				TDs[entry]=((libdict[entry])[1])
	# print(pths);print(TDs);
	if not os.path.exists(cachefolder):
		os.makedirs(cachefolder)				
	for f in os.listdir(cachefolder):
		fp = os.path.join(cachefolder, f)
		try:
			shutil.rmtree(fp)
		except OSError:
			os.remove(fp)	
	if use_archived!=True:				
		print("1. Parsing games in device. Please Wait...")			
		if exclude_xci==True:
			process=subprocess.Popen([nscb_mtp,"ShowInstalled","-tfile",games_installed_cache,"-show","false","-exci","true"],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
		else:	
			process=subprocess.Popen([nscb_mtp,"ShowInstalled","-tfile",games_installed_cache,"-show","false","-exci","false","-xci_lc",xci_locations],stdout=subprocess.PIPE,stderr=subprocess.PIPE)	
		while process.poll()==None:
			if process.poll()!=None:
				process.terminate();	
		if os.path.exists(games_installed_cache):	
			print("   Success")
		gamelist=listmanager.read_lines_to_list(games_installed_cache,all=True)
		installed={}		
		for g in gamelist:
			try:
				if exclude_xci==True:
					if g.endswith('xci') or g.endswith('xc0'):
						continue
				entry=listmanager.parsetags(g)
				entry=list(entry)		
				entry.append(g)
				installed[entry[0]]=entry	
			except:pass	
		# for i in pths:
			# print(i)
	else:
		print("1. Retrieving registered...")			
		dbicsv=os.path.join(cachefolder,"registered.csv")
		process=subprocess.Popen([nscb_mtp,"Download","-ori","4: Installed games\\InstalledApplications.csv","-dst",dbicsv],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
		while process.poll()==None:
			if process.poll()!=None:
				process.terminate();
		if os.path.exists(dbicsv):	
			print("   Success")					
			installed={}
			with open(dbicsv,'rt',encoding='utf8') as csvfile:
				readCSV = csv.reader(csvfile, delimiter=',')
				id=0;ver=1;tname=2;
				for row in readCSV:		
					try:
						tid=(str(row[id]).upper())[2:]
						version=int(row[ver])
						if version>0 and tid.endswith('000'):
							tid=tid[:-3]+'800'						
						name=str(row[tname])
						g=f"{name} [{tid}][v{version}].nsp"
						entry=listmanager.parsetags(g)
						entry=list(entry)		
						entry.append(g)
						if entry[0] in installed.keys():
							if int((intalled[entry[0]])[1])<version:
								installed[entry[0]]=entry
						else:
							installed[entry[0]]=entry							
					except:pass		
	print("2. Parsing files from Google Drive. Please Wait...")		
	# print(pths)
	if isinstance(pths, dict):
		db={}
		for i in pths.keys():
			db[i]={'path':pths[i],'TD_name':TDs[i]}	
		files=concurrent_scrapper(filter='',order='name_ascending',remotelib='all',db=db)
	else:
		db={}
		db[pths]={'path':pths,'TD_name':TDs}			
		files=concurrent_scrapper(filter=filter,order='name_ascending',remotelib='all',db=db)
	remotelist=[]		
	for f in files:
		remotelist.append(f[0])
	if prioritize_nsz==True:		
		remotelist=sorted(remotelist, key=lambda x: x[-1])	
		remotelist.reverse()	
	else:
		remotelist.reverse()
	# for f in remotelist:
		# print(f)
	remotegames={}		
	for g in remotelist:
		try:
			entry=listmanager.parsetags(g)
			entry=list(entry)
			entry.append(g)		
			if not entry[0] in remotegames:
				remotegames[entry[0]]=entry
			else:
				v=(remotegames[entry[0]])[1]
				if int(entry[1])>int(v):
					remotegames[entry[0]]=entry		
		except:pass							
	print("3. Searching new updates. Please Wait...")						
	gamestosend={}		
	for g in installed.keys():
		if g.endswith('000') or g.endswith('800'): 
			try:
				updid=g[:-3]+'800'
				if updid in remotegames:
					if updid in installed:
						if ((installed[updid])[1])<((remotegames[updid])[1]):
							if not updid in gamestosend:
								gamestosend[updid]=remotegames[updid]
							else:
								if ((gamestosend[updid])[1])<((remotegames[updid])[1]):
									gamestosend[updid]=remotegames[updid]
					else:
						if not updid in gamestosend:
							gamestosend[updid]=remotegames[updid]
						else:
							if ((gamestosend[updid])[1])<((remotegames[updid])[1]):
								gamestosend[updid]=remotegames[updid]								
			except:pass
		else:
			try:		
				if g in remotegames:
					if ((installed[g])[1])<((remotegames[g])[1]):
						if not g in gamestosend:
							gamestosend[g]=remotegames[g]
						else:
							if ((gamestosend[g])[1])<((remotegames[g])[1]):
								gamestosend[g]=remotegames[g]
			except:pass							
	print("4. Searching new dlcs. Please Wait...")	
	for g in installed.keys():	
		try:
			if g.endswith('000') or g.endswith('800'): 
				baseid=g[:-3]+'000'
			else:
				baseid=(installed[g])[6]
			for k in remotegames.keys():
				try:				
					if not (k.endswith('000') or k.endswith('800')) and not k in installed:
						test=get_dlc_baseid(k)
						if baseid ==test:
							if not k in gamestosend:
								gamestosend[k]=remotegames[k]
							else:
								if ((gamestosend[k])[1])<((remotegames[k])[1]):
									gamestosend[k]=remotegames[k]	
				except BaseException as e:
					# Print.error('Exception: ' + str(e))			
					pass								
		except BaseException as e:
			# Print.error('Exception: ' + str(e))			
			pass
	print("5. List of content that will get installed...")	
	gamepaths=[]
	if len(gamestosend.keys())>0:
		if autoupd_aut==True:	
			for i in sorted(gamestosend.keys()):
				fileid,fileversion,cctag,nG,nU,nD,baseid,path=gamestosend[i]
				bname=os.path.basename(path) 
				gamepaths.append(path)
				g0=[pos for pos, char in enumerate(bname) if char == '[']	
				g0=(bname[0:g0[0]]).strip()
				print(f"   * {g0} [{fileid}][{fileversion}] [{cctag}] - {(bname[-3:]).upper()}")
		else:
			options=[]
			for i in sorted(gamestosend.keys()):			
				fileid,fileversion,cctag,nG,nU,nD,baseid,path=gamestosend[i]
				bname=os.path.basename(path) 
				gamepaths.append(path)
				g0=[pos for pos, char in enumerate(bname) if char == '[']	
				g0=(bname[0:g0[0]]).strip()
				cstring=f"{g0} [{fileid}][{fileversion}] [{cctag}] - {(bname[-3:]).upper()}"
				options.append(cstring)
			if options:
				from python_pick import Picker
				title = 'Select content to install: \n + Press space or right to select entries \n + Press Enter to confirm selection \n + Press E to exit selection \n + Press A to select all entries'				
				picker = Picker(options, title, multi_select=True, min_selection_count=1)
				def end_selection(picker):
					return False,-1
				def select_all(picker):
					return "ALL",-1			
				picker.register_custom_handler(ord('e'),  end_selection)
				picker.register_custom_handler(ord('E'),  end_selection)
				picker.register_custom_handler(ord('a'),  select_all)
				picker.register_custom_handler(ord('A'),  select_all)	
				selected=picker.start()					
			if selected[0]==False:
				print("    User didn't select any files")
				return False					
			if selected[0]=="ALL":		
				pass
			else:
				newgpaths=[]
				for game in selected:
					g=game[1]
					g0=gamepaths[g]
					newgpaths.append(g0)
				gamepaths=newgpaths					
		print("6. Generating text file...")		
		with open(tfile,'w', encoding='utf8') as textfile:
			wpath=''
			for i in gamepaths:
				location=None
				for f in files:
					TD=None;ID=None
					if f[0]==i:	
						location=f[2]
						try:
							ID=f[4]
						except:pass	
						break
				if location==None:
					print(f"Can't find location for {i}")
					continue
				wpath=f"{location}/{i}"
				lib,TD,libpath=get_library_from_path(filename=wpath)
				if ID==None:
					textfile.write(f"{(wpath).strip()}|{TD}\n")
				else:		
					textfile.write(f"{(wpath).strip()}|{TD}|{ID}\n")	
		print("7. Triggering installer on loop mode.")
		print("   Note:If you interrupt the list use normal install mode to continue list")	
		loop_install(tfile,destiny=destiny,outfolder=None,ch_medium=ch_medium,check_fw=True,patch_keygen=False,ch_base=False,ch_other=False,checked=True)
	else:
		print("\n   --- DEVICE IS UP TO DATE ---")					
Exemple #17
0
def generate_multixci_and_transfer(tfile=None,outfolder=None,destiny="SD",kgpatch=False,verification=False):
	if destiny==False or destiny=="pick" or destiny=="":
		destiny=pick_transfer_folder()	
	if destiny=="SD":
		destiny="1: External SD Card\\"
	from mtpinstaller import get_storage_info,get_DB_dict
	tgkg=0;kgwarning=False
	if tfile=="":
		tfile=None	
	if tfile==None:
		print("File input = null")
		return False	
	if not os.path.exists(tfile):
		sys.exit(f"Couldn't find {tfile}")			
	if outfolder=="":
		outfolder=None			
	if outfolder==None:
		outfolder=cachefolder
		if not os.path.exists(cachefolder):
			os.makedirs(cachefolder)
	if not os.path.exists(outfolder):
		os.makedirs(outfolder)	
	for f in os.listdir(outfolder):
		fp = os.path.join(outfolder, f)
		try:
			shutil.rmtree(fp)
		except OSError:
			os.remove(fp)	
	file_list=listmanager.read_lines_to_list(tfile,all=True)
	if verification==True or str(verification).upper()=="HASH":	
		verdict=False
		for fp in file_list:	
			if str(verification).upper()=="HASH":
				verdict,isrestored,cnmt_is_patched=file_verification(fp,hash=True)		
			else:
				verdict,isrestored,cnmt_is_patched=file_verification(fp)
			if verdict==False:
				print(f"{fp} didn't pass verification. Skipping {tfile}")
				return False						
	dopatch=False		
	print("- Retrieving Space on device")
	SD_ds,SD_fs,NAND_ds,NAND_fs,FW,device=get_storage_info()			
	print("- Calculating Size")	
	fullxcisize=0;maxkg=0
	for fp in file_list:	
		head_xci_size,keygeneration,sz=get_header_size(fp)
		installedsize=head_xci_size+sz
		fullxcisize+=installedsize
		if int(maxkg)<int(keygeneration):
			maxkg=keygeneration
	print(f"  * SD free space: {SD_fs} ({sq_tools.getSize(SD_fs)})")	
	print(f"  * File installed size: {installedsize} ({sq_tools.getSize(installedsize)})")
	if installedsize>SD_fs:
		sys.exit("   NOT ENOUGH SPACE SD STORAGE")		
	if kgpatch==True:	
		if FW!='unknown':	
			try:
				FW_RSV,RRSV=sq_tools.transform_fw_string(FW)
				FW_kg=sq_tools.kg_by_RSV(FW_RSV)
			except BaseException as e:
				Print.error('Exception: ' + str(e))
				FW='unknown'
				FW_kg='unknown'
				pass
		if FW!='unknown' and FW_kg!='unknown':			
			if int(keygeneration)>int(FW_kg):
				kgwarning=True
				tgkg=int(FW_kg)
			else:
				tgkg=keygeneration
		else:
			tgkg=keygeneration
		print(f"- Console Firmware: {FW} ({FW_RSV}) - keygen {FW_kg})")		
		print(f"- File keygeneration: {keygeneration}")				
	else:
		tgkg=keygeneration
	if kgwarning==True: 	
		print("File requires a higher firmware. It'll will be prepatch")
		dopatch=True	
	keypatch=int(tgkg)	
	
	if isExe==False:
		process0=subprocess.Popen([sys.executable,squirrel,"-b","65536","-pv","true","-kp",str(keypatch),"--RSVcap","268435656","-fat","exfat","-fx","files","-ND","true","-t","xci","-o",outfolder,"-tfile",tfile,"-roma","TRUE","-dmul","calculate"])
	else:
		process0=subprocess.Popen([squirrel,"-b","65536","-pv","true","-kp",str(keypatch),"--RSVcap","268435656","-fat","exfat","-fx","files","-ND","true","-t","xci","-o",outfolder,"-tfile",tfile,"-roma","TRUE","-dmul","calculate"])	
	while process0.poll()==None:
		if process0.poll()!=None:
			process0.terminate();
	files2transfer=listmanager.folder_to_list(outfolder,['xci'])
	for f in files2transfer:
		bname=str(os.path.basename(f))
		destinypath=os.path.join(destiny,bname)
		process=subprocess.Popen([nscb_mtp,"Transfer","-ori",f,"-dst",destinypath])		
		while process.poll()==None:
			if process.poll()!=None:
				process.terminate();	
	try:			
		for f in os.listdir(outfolder):
			fp = os.path.join(outfolder, f)
			try:
				shutil.rmtree(fp)
			except OSError:
				os.remove(fp)	
	except:pass		
Exemple #18
0
def get_gamelist(dosort=True, file=games_installed_cache):
    gamelist = []
    if os.path.exists(file):
        gamelist = listmanager.read_lines_to_list(file, all=True)
        gamelist.sort()
    return gamelist