mirror of
https://github.com/thewesker/lazy-dsi-file-downloader.git
synced 2025-12-20 04:21:09 -05:00
Update main.py
This commit is contained in:
19
main.py
19
main.py
@@ -6,8 +6,7 @@
|
|||||||
|
|
||||||
#Import libraries
|
#Import libraries
|
||||||
import tkinter
|
import tkinter
|
||||||
from tkinter import messagebox
|
from tkinter import messagebox, filedialog
|
||||||
from tkinter import filedialog
|
|
||||||
import tkinter.font
|
import tkinter.font
|
||||||
import tkinter.ttk
|
import tkinter.ttk
|
||||||
import os
|
import os
|
||||||
@@ -45,6 +44,7 @@ def downloadFile(link, destination):
|
|||||||
print("File not available, skipping...")
|
print("File not available, skipping...")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
#Used to verify if file has been downloaded properly
|
||||||
def hashcreator(filetobechecked):
|
def hashcreator(filetobechecked):
|
||||||
string = hashlib.blake2b(open(filetobechecked,'rb').read()).hexdigest()
|
string = hashlib.blake2b(open(filetobechecked,'rb').read()).hexdigest()
|
||||||
return string
|
return string
|
||||||
@@ -88,11 +88,13 @@ def validateDirectory(directory):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
#Unzips .zip files
|
||||||
def unzipper(unzipped, destination):
|
def unzipper(unzipped, destination):
|
||||||
with zipfile.ZipFile(unzipped, 'r') as zip_ref:
|
with zipfile.ZipFile(unzipped, 'r') as zip_ref:
|
||||||
zip_ref.extractall(destination)
|
zip_ref.extractall(destination)
|
||||||
zip_ref.close()
|
zip_ref.close()
|
||||||
|
|
||||||
|
#Unzips .7z files
|
||||||
def un7zipper(_7za, zipfile, destination):
|
def un7zipper(_7za, zipfile, destination):
|
||||||
proc = Popen([_7za,"x", "-aoa", zipfile, '-o'+destination])
|
proc = Popen([_7za,"x", "-aoa", zipfile, '-o'+destination])
|
||||||
|
|
||||||
@@ -103,7 +105,7 @@ def un7zipper(_7za, zipfile, destination):
|
|||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
|
#Main "install" process
|
||||||
def start():
|
def start():
|
||||||
|
|
||||||
#Clear outputBox
|
#Clear outputBox
|
||||||
@@ -153,7 +155,7 @@ def start():
|
|||||||
|
|
||||||
lineCounter = 0
|
lineCounter = 0
|
||||||
|
|
||||||
#Variables
|
#Get variables from tkinter
|
||||||
directory = SDentry
|
directory = SDentry
|
||||||
version = firmwareVersion.get()
|
version = firmwareVersion.get()
|
||||||
unlaunchNeeded = unlaunch.get()
|
unlaunchNeeded = unlaunch.get()
|
||||||
@@ -168,7 +170,7 @@ def start():
|
|||||||
elif dsiVersions.index(version) in [0,2]:
|
elif dsiVersions.index(version) in [0,2]:
|
||||||
memoryPitDownload = memoryPitLinks[0]
|
memoryPitDownload = memoryPitLinks[0]
|
||||||
|
|
||||||
#Creates a path called "/lazy-dsi-file-downloader-tmp/" if it does not exist
|
#Creates a temporary path called "/lazy-dsi-file-downloader-tmp/" if it does not exist
|
||||||
cwdtemp = os.getcwd() + "/lazy-dsi-file-downloader-tmp/"
|
cwdtemp = os.getcwd() + "/lazy-dsi-file-downloader-tmp/"
|
||||||
Path(cwdtemp).mkdir(parents=True,exist_ok=True)
|
Path(cwdtemp).mkdir(parents=True,exist_ok=True)
|
||||||
|
|
||||||
@@ -278,6 +280,7 @@ def start():
|
|||||||
print("Downloading other homebrew...")
|
print("Downloading other homebrew...")
|
||||||
|
|
||||||
|
|
||||||
|
#Downloads for homebrew options selected in "other homebrew" list
|
||||||
for count, item in enumerate(homebrewDB):
|
for count, item in enumerate(homebrewDB):
|
||||||
if homebrewList[count].get() == 1:
|
if homebrewList[count].get() == 1:
|
||||||
print("Downloading "+item["title"])
|
print("Downloading "+item["title"])
|
||||||
@@ -324,17 +327,18 @@ def start():
|
|||||||
outputbox("Done!\n")
|
outputbox("Done!\n")
|
||||||
outputbox("Press the Finish button to continue... \n")
|
outputbox("Press the Finish button to continue... \n")
|
||||||
|
|
||||||
|
#Tkinter directory popup dialog
|
||||||
def chooseDir(source,SDentry):
|
def chooseDir(source,SDentry):
|
||||||
source.sourceFolder = filedialog.askdirectory(parent=source, initialdir= "/", title='Please select the directory of your SD card')
|
source.sourceFolder = filedialog.askdirectory(parent=source, initialdir= "/", title='Please select the directory of your SD card')
|
||||||
SDentry.delete(0, tkinter.END)
|
SDentry.delete(0, tkinter.END)
|
||||||
SDentry.insert(0, source.sourceFolder)
|
SDentry.insert(0, source.sourceFolder)
|
||||||
|
|
||||||
|
#Used to close additional homebrew menu
|
||||||
def okButtonPress(self,source):
|
def okButtonPress(self,source):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
source.deiconify()
|
source.deiconify()
|
||||||
|
|
||||||
|
#Extra homebrew window list
|
||||||
def extraHomebrew(source):
|
def extraHomebrew(source):
|
||||||
homebrewWindow = tkinter.Toplevel(source)
|
homebrewWindow = tkinter.Toplevel(source)
|
||||||
homebrewWindow.config(bg="#f0f0f0")
|
homebrewWindow.config(bg="#f0f0f0")
|
||||||
@@ -380,6 +384,7 @@ def closeButtonPress(source):
|
|||||||
def nextWindow(windownumbertosummon):
|
def nextWindow(windownumbertosummon):
|
||||||
globals()["summonWindow"+windownumbertosummon]
|
globals()["summonWindow"+windownumbertosummon]
|
||||||
|
|
||||||
|
#Needed to disable buttons
|
||||||
def donothing():
|
def donothing():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user