def make_repo(): new_dict = { "homebrew": repos.homebrewlist, "emulators": repos.emulist, "games": repos.gameslist, "media": repos.medialist, "python": repos.nxpythonlist, "cfw": repos.customfirmwarelist, "payloads": repos.payloadlist, } for genre in new_dict.keys(): for software_item in new_dict[genre]: updatefile = webhandler.getJson(software_item["name"], software_item["githubapi"]) if not updatefile: sys.exit("ERROR BUILDING REPO FILE: Failed to get json for {}". format(software_item["name"])) with open(updatefile, encoding="utf-8") as update_file_object: json_data = json.load(update_file_object) software_item["github_content"] = json_data software_item["downloads"] = get_downloads(software_item, json_data) old_dict = None if os.path.isfile(new_repo): with open(new_repo) as old: old_dict = json.load(old) #if the repo has changed if new_dict == old_dict: print("No data has changed.") else: print("Content has changed, updating repo {}".format(REPOFILENAME)) #Make 1-instance backup if os.path.isfile(new_repo): shutil.move(new_repo, old_repo) #Print the new data print(json.dumps(new_dict, indent=4)) with open(REPOFILENAME, 'w+') as outfile: json.dump(new_dict, outfile, indent=4)
except: print("Failed to set window type to borderless") gui.mainloop() parsed_args = None if len(sys.argv) > 1: arg_parser = create_arg_parser() parsed_args = arg_parser.parse_args(sys.argv[1:]) if not parsed_args: # Launch normally, get updated repo file print("Getting updated homebrew repository file") print(f"Console / Repository - {config.CONSOLE}") packages_json = getJson("repo", config.REPO_JSON_URL) if not packages_json: print( "Failed to download packages json repo file, falling back on cached version" ) else: # Launching with `python3 script.py test` will allow # you to test gui changes without hitting the repo # uses cached json if parsed_args.repo.lower() == "test": print("Using local json") packages_json = getCachedJson("repo") else: print(f"Using passed repo json {parsed_args.repo}") packages_json = parsed_args.repo
from webhandler import getJson from modules.locations import appstore_repo_url from asyncthreader import asyncThreader from github_updater import updater from widgets import icon_dict from pages import pagelist print("Checking for updates...") if updater.check_for_update(version): print("Update detected.") #Async threader tool for getting downloads and other functions asyncronously threader = asyncThreader() #Download the appstore json, uses etagging to check if it needs an update to minimize bandwidth print("Getting updated appstore repo file") store_json = getJson("appstore_repo", appstore_repo_url) #Parse the json into categories repo_parser = parser() repo_parser.blacklist_categories(["loader", "theme"]) threader.do_async(repo_parser.load, [store_json], priority="high") #Shared tool for installing and managing hbas apps via the switchbru site on the sd card store_handler = appstore_handler() image_sharer = icon_dict() geometry = {"width": 780, "height": 575} def startGUI(): #frameManager serves to load all pages and stack them on top of each other (all 2 of them) #also serves to make many important objects and functions easily available to children frames
if not os.path.exists('downloads'): os.mkdir('downloads') try: # Start tkinter then immediately close the root window, this # prevents a tkinter root window from popping up but lets tkinter # run in the background so we can use its file dialog utility tkinter.Tk().withdraw() packages_to_install = [ "Atmosphere", #CFW "lennytube", #Youtube homebrew alternative ] #Download the appstore team's repo with etagging repo = getJson('repo', 'https://www.switchbru.com/appstore/repo.json') repo_parser = parser() #Load the repo file repo_parser.load_file(repo) #Get the path to a switch SD card with a simple pop-up dialog chosensdpath = filedialog.askdirectory(initialdir="/", title='Please select your SD card') #Handler for dealing with SD card contents store_handler = appstore_handler() #Set handler's working directory to the base directory of the SD card store_handler.set_path(chosensdpath) #Check if the appstore .get folder has been initiated here if not store_handler.check_if_get_init(): store_handler.init_get() for package in packages_to_install:
def get_file(self): # return getCachedJson(self.name) return getJson(self.name, self.repo_domain + "repo.json")
arg_parser = create_arg_parser() parsed_args = arg_parser.parse_args(sys.argv[1:]) toolsfolder = os.path.join(sys.path[0], "tools") if not os.path.isdir(toolsfolder): print("Initing tools folder") os.mkdir(toolsfolder) #Tool to manage local packages (downloaded payloads, etc) local_packages_handler.set_path(toolsfolder, silent = True) #Init tracking file for local packages as needed if not local_packages_handler.check_if_get_init(): local_packages_handler.init_get() if not parsed_args: print("Getting updated HBUpdater api file") repos_github_api = getJson("repos_api","https://api.github.com/repos/LyfeOnEdge/HBUpdater_API/releases") if repos_github_api: with open(repos_github_api, encoding = "utf-8") as package_repos: repo = json.load(package_repos) assets = repo[0]["assets"] #Borrow HBUpdater findasset function repo_remote = local_packages_handler.findasset([["repo"], "json"], assets, silent = True) print("Getting updated HBUpdater repo file") packages_json = getJson("repos",repo_remote) else: print("Failed to download packages json repo file, falling back on old version") packages_json = os.path.join(sys.path[0], "cache/json/repos.json") else: if parsed_args.repo.lower() == "test": print("Using local json") packages_json = getCachedJson("repos")
def get_file(self): return getJson(self.name, self.repo_domain + "repo.json")