From 14013d60e212c41f8903f3a12e031430131f4505 Mon Sep 17 00:00:00 2001 From: Andrew Date: Tue, 4 Jun 2019 22:15:08 -0700 Subject: [PATCH] Minor tweaks installerhelperpage's functions have been moved to toolhelper.py in modules --- .gitignore | 1 + HBUpdaterGUI.py | 3 +- assets/github.png | Bin 0 -> 1493 bytes modules/customwidgets.py | 6 +- modules/toolhelper.py | 143 +++++++++++++++++++++++++ pages/errorpage.py | 6 +- pages/homepage.py | 38 ++++--- pages/installerhelperpage.py | 201 ----------------------------------- pages/serialpage.py | 1 - todo.md | 2 + 10 files changed, 174 insertions(+), 227 deletions(-) create mode 100644 assets/github.png create mode 100644 modules/toolhelper.py delete mode 100644 pages/installerhelperpage.py diff --git a/.gitignore b/.gitignore index e2cdf70..0753638 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ /titledb/* /conf/* /tools/* +/titles/* user_repos.json fluffy.conf fluffy.log diff --git a/HBUpdaterGUI.py b/HBUpdaterGUI.py index b3d6839..9df72d9 100644 --- a/HBUpdaterGUI.py +++ b/HBUpdaterGUI.py @@ -55,7 +55,6 @@ def __init__(self, *args, **kwargs): import pages.mainpage as mp import pages.settingspage as sp import pages.addrepopage as ar - import pages.installerhelperpage as hp import pages.pythonnxpage as py import pages.cfwpage as fw import pages.errorpage as ep @@ -65,7 +64,7 @@ def __init__(self, *args, **kwargs): self.frames = {} #Add frames to dict, with keyword being the name of the frame - for F in (mp.mainPage,ip.injectorScreen,sp.settingsPage,ar.addRepoScreen,hp.installerHelperPage,py.pynxPage,fw.cfwPage,ep.errorPage,lp.homePage,gp.gamesPage,cp.serialPage): + for F in (mp.mainPage,ip.injectorScreen,sp.settingsPage,ar.addRepoScreen,py.pynxPage,fw.cfwPage,ep.errorPage,lp.homePage,gp.gamesPage,cp.serialPage): page_name = F.__name__ frame = F(parent=container, controller=self,back_command = lambda: self.show_frame("homePage")) self.frames[page_name] = frame diff --git a/assets/github.png b/assets/github.png new file mode 100644 index 0000000000000000000000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&-2uAeKOaaq15N^yqHq*N z4S;j*yn6o+pkDWm$BNWDk}gj8IdpjbdETDX`f@M%w?Rk16Z$gd4CwHD%kpO8095$$ zxG{^tha&1cltovg=c!OW!tV`hfjt=)thPnewJqbK(;i@5)U_V#Tfk`iXi1fRXmP 2.8: + asset = 1 + else: + asset = 0 + scripturl = jfile[0]["assets"][asset]["browser_download_url"] + licenseurl = jfile[0]["assets"][asset+1]["browser_download_url"] + + + #download and move fluffy and license + script = webhandler.download(scripturl) + license = webhandler.download(licenseurl) + scriptpath = os.path.join(locations.downloadsfolder, script) + licensepath = os.path.join(locations.downloadsfolder, license) + newscriptpath = os.path.join(locations.fluffyfolder, script) + newlicensepath = os.path.join(locations.fluffyfolder, license) + shutil.move(scriptpath,newscriptpath) + shutil.move(licensepath,newlicensepath) + + newentry = { + "fluffy" : { + "version": version, + "location": newscriptpath, + } + } + guicore.setguisetting(newentry) + + print("checking and installing fluffy dependencies") + + threads = [] + dependencies = locations.fluffydict["dependencies"] + webhandler.installmodulelist(dependencies) + + + diff --git a/pages/errorpage.py b/pages/errorpage.py index a71f2fc..d551f0f 100644 --- a/pages/errorpage.py +++ b/pages/errorpage.py @@ -25,16 +25,16 @@ def __init__(self, parent, controller,back_command): self.backbuttonframe = cw.themedframe(self,background_color=dark_color) self.backbuttonframe.place(relx=0.5,rely=0.5,y=+(3*navbuttonheight + separatorwidth),width=300,x=-150,height=navbuttonheight) - self.backbutton = cw.navbutton(self.backbuttonframe, command_name=self.back_command,text_string="RIP. Take me back to the app.") + self.backbutton = cw.navbutton(self.backbuttonframe, command_name=self.back_command,text_string="RIP. Take me back to the app.",background=light_color) self.backbutton.place(relwidth=1,relheight=1) self.yesnobuttonframe = cw.themedframe(self,background_color=dark_color) self.yesnobuttonframe.place(relx=0.5,rely=0.5,y=+(3*navbuttonheight + separatorwidth),width=300,x=-150,height=navbuttonheight) - self.yesbutton = cw.navbutton(self.yesnobuttonframe, command_name=self.on_yes,text_string="Yes") + self.yesbutton = cw.navbutton(self.yesnobuttonframe, command_name=self.on_yes,text_string="Yes",background=light_color) self.yesbutton.place(relx=0,relwidth=0.33,relheight=1) - self.nobutton = cw.navbutton(self.yesnobuttonframe, command_name=self.on_no,text_string="No") + self.nobutton = cw.navbutton(self.yesnobuttonframe, command_name=self.on_no,text_string="No",background=light_color) self.nobutton.place(relx=0.67,relwidth=0.33,relheight=1) self.backbuttonframe.tkraise() diff --git a/pages/homepage.py b/pages/homepage.py index d903a26..d79f34a 100644 --- a/pages/homepage.py +++ b/pages/homepage.py @@ -9,7 +9,7 @@ import tkinter as tk from tkinter.constants import * -import pages.installerhelperpage as installerhelperpage +import modules.toolhelper as toolhelper import pages.serialpage as serialpage import pages.errorpage as errorpage homebuttonwidth = 120 @@ -49,6 +49,7 @@ def __init__(self, parent, controller,back_command): self.betaimage = tk.PhotoImage(file=os.path.join(locations.assetfolder, "beta.png")) self.homebrewimage = tk.PhotoImage(file=os.path.join(locations.assetfolder, "homebrew.png")) self.gameimage = tk.PhotoImage(file=os.path.join(locations.assetfolder, "games.png")) + self.githubimage = tk.PhotoImage(file=os.path.join(locations.assetfolder, "github.png")) homebrewbuttonlist = [ { @@ -113,20 +114,19 @@ def __init__(self, parent, controller,back_command): otherbuttonlist = [ - { - "image" : self.betaimage, - "callback" : lambda: self.controller.show_frame("errorPage"), - "tooltip" : "Whatever is in beta", - "shorttip" : "In beta" - }, - - { "image" : self.settingsimage, "callback" : lambda: self.controller.show_frame("settingsPage"), "tooltip" : "Open settings page", "shorttip" : "Settings" }, + + { + "image" : self.githubimage, + "callback" : lambda: webhandler.opentab(), + "tooltip" : "Open HBUpdater Github", + "shorttip" : "HBU Github" + }, ] @@ -149,18 +149,22 @@ def __init__(self, parent, controller,back_command): separator.place(relx=0,rely=0.65,relwidth=1,height=separatorwidth) def checknutandstart(self): - if not installerhelperpage.checkifhelperdownloaded("nut"): - installerhelperpage.seterrorstate("nut") - self.controller.show_frame("installerHelperPage") + if not toolhelper.checkifhelperdownloaded("nut"): + self.controller.show_frame("errorPage") + self.controller.frames["errorPage"].getanswer("homePage","It looks like you don't have nut installed yet,\nwould you like to install it and its dependencies?\nThis can take up to a minute",toolhelper.getnut) return - installerhelperpage.starthelper("nut") + else: + toolhelper.starthelper("nut") + def checkfluffyandstart(self): - if not installerhelperpage.checkifhelperdownloaded("fluffy"): - installerhelperpage.seterrorstate("fluffy") - self.controller.show_frame("installerHelperPage") + if not toolhelper.checkifhelperdownloaded("fluffy"): + self.controller.show_frame("errorPage") + self.controller.frames["errorPage"].getanswer("homePage","It looks like you don't have fluffy installed yet,\nwould you like to install it and its dependencies?\nThis can take up to a minute",toolhelper.getfluffy) return - installerhelperpage.starthelper("fluffy") + else: + toolhelper.starthelper("fluffy") + def checkserialandstart(self): status = serialpage.checkifSSNCinstalled() diff --git a/pages/installerhelperpage.py b/pages/installerhelperpage.py deleted file mode 100644 index ca07727..0000000 --- a/pages/installerhelperpage.py +++ /dev/null @@ -1,201 +0,0 @@ -from modules.format import * -import modules.customwidgets as cw -import modules.guicore as guicore -import modules.HBUpdater as HBUpdater -import modules.locations as locations -import modules.webhandler as webhandler - -import json, os, shutil, subprocess, sys, threading - -from zipfile import ZipFile -import tkinter as tk - - -errorstate = None -fluffylist = [] - -class installerHelperPage(tk.Frame,): - def __init__(self, parent, controller,back_command): - tk.Frame.__init__(self,parent) - self.bind("<>", self.on_show_frame) - self.controller=controller - self.back_command = back_command - - self.returnimage = tk.PhotoImage(file=os.path.join(locations.assetfolder,"returnbutton.png")).zoom(3).subsample(5) - - - #page for warning users that nut isn't installed and asking if they want to install it - self.installerwarningframe = cw.themedframe(self,) - self.installerwarningframe.place(relwidth=1,relheight=1) - self.returnbutton = cw.navbutton(self.installerwarningframe, image_object=self.returnimage, command_name=self.controller.show_frame("mainPage")) - self.returnbutton.place(relx=1, rely=1, x=-(separatorwidth+navbuttonheight), y=-(separatorwidth+navbuttonheight), height=navbuttonheight, width=navbuttonheight) - - self.nutnotdownloadedwarningframe= cw.themedframe(self.installerwarningframe) - self.nutnotdownloadedwarningframe.place(relheight=1,relwidth=1) - self.nutnotdownloadedwarning = cw.themedguidelabel(self.nutnotdownloadedwarningframe,"IT LOOKS LIKE YOU DON'T HAVE NUT DOWNLOADED YET,\n WOULD YOU LIKE TO DOWNLOAD IT AND INSTALL ITS DEPENDENCIES?",anchor="center") - self.nutnotdownloadedwarning.place(relx=0.5,rely=0.5,x=-250, width=500,height=3*navbuttonheight,y=-(1.5*navbuttonheight)) - self.installnutbutton = cw.navbutton(self.nutnotdownloadedwarningframe, command_name=self.getnut,text_string="YES") - self.installnutbutton.place(relx=0.5,rely=0.5,y=+(2*navbuttonheight + separatorwidth),width=100,x=-50) - self.nutcancelbutton = cw.navbutton(self.nutnotdownloadedwarningframe, command_name=back_command,text_string="NO") - self.nutcancelbutton.place(relx=0.5,rely=0.5,y=+(3*navbuttonheight + separatorwidth),width=100,x=-50) - - - self.fluffynotdownloadedwarningframe= cw.themedframe(self.installerwarningframe) - self.fluffynotdownloadedwarningframe.place(relheight=1,relwidth=1) - self.fluffynotdownloadedwarning = cw.themedguidelabel(self.fluffynotdownloadedwarningframe,"IT LOOKS LIKE YOU DON'T HAVE FLUFFY DOWNLOADED YET,\n WOULD YOU LIKE TO DOWNLOAD IT AND INSTALL ITS DEPENDENCIES?",anchor="center") - self.fluffynotdownloadedwarning.place(relx=0.5,rely=0.5,x=-250, width=500,height=3*navbuttonheight,y=-(1.5*navbuttonheight)) - self.installfluffybutton = cw.navbutton(self.fluffynotdownloadedwarningframe, command_name=self.getfluffy,text_string="YES") - self.installfluffybutton.place(relx=0.5,rely=0.5,y=+(2*navbuttonheight + separatorwidth),width=100,x=-50) - self.fluffycancelbutton = cw.navbutton(self.fluffynotdownloadedwarningframe, command_name=back_command,text_string="NO") - self.fluffycancelbutton.place(relx=0.5,rely=0.5,y=+(3*navbuttonheight + separatorwidth),width=100,x=-50) - - - self.nutnotdownloadedwarningframe.tkraise() - - - def on_show_frame(self,event): - global errorstate - if errorstate == "nut": - self.nutnotdownloadedwarningframe.tkraise() - if errorstate == "fluffy": - self.fluffynotdownloadedwarningframe.tkraise() - - - def getnut(self): - downloadNUTandinstalldependencies() - - self.back_command() - starthelper("nut") - - def getfluffy(self): - downloadFLUFFYandinstalldependencies() - self.back_command() - starthelper("fluffy") - -def seterrorstate(state): - global errorstate - errorstate = state - -def checkifhelperdownloaded(helper): - if guicore.checkguisetting(helper, "version") == "not installed" or guicore.checkguisetting(helper, "version") == None: - return False - else: - print(guicore.checkguisetting(helper, "version")) - return True - return False - -def starthelper(helper): - if not checkifhelperdownloaded(helper): - nutnotdownloadedwarningframe.tkraise() - print("not installed") - return - script_path = guicore.checkguisetting(helper, "location") - print("starting {} server at {}".format(helper,script_path)) - if script_path == None: - print("invalid path") - return - subprocess.Popen([sys.executable,script_path]) - -def downloadNUTandinstalldependencies(): - if not os.path.isdir(locations.nutfolder): - os.mkdir(locations.nutfolder) - print("initializing nut folder") - - nutjson = webhandler.getJson("nut", locations.nutserverdict["githubapi"]) - with open(nutjson) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - if jfile == [] or jfile == None: - print("Error: empty json nut file") - return - - zipurl = jfile[0]["zipball_url"] - version = jfile[0]["tag_name"] - if zipurl == None: - print("zip file url invalid, can't download nut assets") - - nutzip = webhandler.download(zipurl) - nutzip = os.path.join(locations.downloadsfolder, nutzip) - - with ZipFile(nutzip, 'r') as zipObj: - zipObj.extractall(locations.nutfolder) - print("Sucessfully extracted {} to nut folder\n".format(nutzip)) - - extractedfiles = zipObj.namelist() - - serverfile = None - for possibleserverfile in extractedfiles: - if possibleserverfile == extractedfiles[0] + "server.py": - serverfile = possibleserverfile - if serverfile == None: - print("Could not find server file in extracted files") - return - - serverfile = os.path.join(locations.nutfolder, serverfile) - - newentry = { - "nut" : { - "version": version, - "location": serverfile, - } - } - guicore.setguisetting(newentry) - - print("checking nut dependencies") - - dependencies = locations.nutserverdict["dependencies"] - webhandler.installmodulelist(dependencies) - -def downloadFLUFFYandinstalldependencies(): - if not os.path.isdir(locations.fluffyfolder): - os.mkdir(locations.fluffyfolder) - print("initializing fluffy folder") - - global fluffylist - if fluffylist == []: - fluffydict = locations.fluffydict - fluffylist = [fluffydict] - fluffylist = webhandler.getUpdatedSoftwareLinks(fluffylist) - - fluffyjson = fluffylist[0]["githubjson"] - with open(fluffyjson) as json_file: #jsonfile is path, json_file is file obj - jfile = json.load(json_file) - if jfile == [] or jfile == None: - print("Error: empty json nut file") - return - - version = jfile[0]["tag_name"] - version = version.strip("v") - if float(version) > 2.8: - asset = 1 - else: - asset = 0 - scripturl = jfile[0]["assets"][asset]["browser_download_url"] - licenseurl = jfile[0]["assets"][asset+1]["browser_download_url"] - - - #download and move fluffy and license - script = webhandler.download(scripturl) - license = webhandler.download(licenseurl) - scriptpath = os.path.join(locations.downloadsfolder, script) - licensepath = os.path.join(locations.downloadsfolder, license) - newscriptpath = os.path.join(locations.fluffyfolder, script) - newlicensepath = os.path.join(locations.fluffyfolder, license) - shutil.move(scriptpath,newscriptpath) - shutil.move(licensepath,newlicensepath) - - newentry = { - "fluffy" : { - "version": version, - "location": newscriptpath, - } - } - guicore.setguisetting(newentry) - - print("checking and installing fluffy dependencies") - - threads = [] - dependencies = locations.fluffydict["dependencies"] - webhandler.installmodulelist(dependencies) - - - diff --git a/pages/serialpage.py b/pages/serialpage.py index 6e4cc98..83843de 100644 --- a/pages/serialpage.py +++ b/pages/serialpage.py @@ -10,7 +10,6 @@ import tkinter as tk from tkinter.constants import * -import pages.installerhelperpage as installerhelperpage import pages.errorpage as errorpage serialboxheight = 90 diff --git a/todo.md b/todo.md index cd907b3..5b39675 100644 --- a/todo.md +++ b/todo.md @@ -15,6 +15,7 @@ Priority: stop crash when initial json fails to download [MEDIUM] features: improve repo management and addition [MEDIUM] + github 304 rate limiting avoidance [HARD] Medium: features: @@ -60,6 +61,7 @@ todone: removed homebrewcore.py to simplify backend download - on - demand serial checker nut, fluffy, serial checker, payload injector, etc download into a tools subfolder for better folder structure + installerhelperpage's functions have been moved to toolhelper.py in modules, the giu code has been taken over by errorpage.py