mirror of
https://github.com/thewesker/lazy-dsi-file-downloader.git
synced 2025-12-20 04:21:09 -05:00
Commit to please the flake8 Gods
This commit is contained in:
174
main.py
174
main.py
@@ -4,9 +4,7 @@
|
|||||||
# https://github.com/YourKalamity/lazy-dsi-file-downloader
|
# https://github.com/YourKalamity/lazy-dsi-file-downloader
|
||||||
|
|
||||||
|
|
||||||
#Import libraries
|
|
||||||
import tkinter
|
import tkinter
|
||||||
from tkinter import messagebox
|
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
import tkinter.font
|
import tkinter.font
|
||||||
import tkinter.ttk
|
import tkinter.ttk
|
||||||
@@ -20,52 +18,63 @@ import shutil
|
|||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
import zipfile
|
import zipfile
|
||||||
import distutils
|
import distutils
|
||||||
from distutils import dir_util
|
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import threading
|
import threading
|
||||||
from requests.exceptions import ConnectionError
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
pageNumber = 0
|
pageNumber = 0
|
||||||
|
|
||||||
#Memory Pit Links - Points to GitHub repo
|
dsiVersions = [
|
||||||
dsiVersions = ["1.0 - 1.3 (USA, EUR, AUS, JPN)", "1.4 - 1.4.5 (USA, EUR, AUS, JPN)", "All versions (KOR, CHN)"]
|
"1.0 - 1.3 (USA, EUR, AUS, JPN)",
|
||||||
memoryPitLinks = ["https://github.com/YourKalamity/just-a-dsi-cfw-installer/raw/master/assets/files/memoryPit/256/pit.bin","https://github.com/YourKalamity/just-a-dsi-cfw-installer/raw/master/assets/files/memoryPit/768_1024/pit.bin"]
|
"1.4 - 1.4.5 (USA, EUR, AUS, JPN)",
|
||||||
|
"All versions (KOR, CHN)"
|
||||||
|
]
|
||||||
|
|
||||||
|
linkToRepo = "https://github.com/YourKalamity/lazy-dsi-file-downloader"
|
||||||
|
|
||||||
|
memoryPitLinks = [
|
||||||
|
linkToRepo + "/raw/master/assets/files/memoryPit/256/pit.bin",
|
||||||
|
linkToRepo + "/raw/master/assets/files/memoryPit/768_1024/pit.bin"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
#Downloader
|
|
||||||
def downloadFile(link, destination):
|
def downloadFile(link, destination):
|
||||||
try:
|
try:
|
||||||
r = requests.get(link, allow_redirects=True)
|
r = requests.get(link, allow_redirects=True)
|
||||||
if link.find('/'):
|
if link.find('/'):
|
||||||
fileName = link.rsplit('/', 1)[1]
|
fileName = link.rsplit('/', 1)[1]
|
||||||
if destination.endswith("/") == False:
|
if destination.endswith("/") is False:
|
||||||
destination = destination + "/"
|
destination = destination + "/"
|
||||||
downloadLocation = destination + fileName
|
downloadLocation = destination + fileName
|
||||||
open(downloadLocation, 'wb').write(r.content)
|
open(downloadLocation, 'wb').write(r.content)
|
||||||
return downloadLocation
|
return downloadLocation
|
||||||
except ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
print(e)
|
print(e)
|
||||||
print("File not available, skipping...")
|
print("File not available, skipping...")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
#Get link of latest Github Release
|
|
||||||
def getLatestGitHub(usernamerepo, assetNumber):
|
def getLatestGitHub(usernamerepo, assetNumber):
|
||||||
release = json.loads(requests.get("https://api.github.com/repos/"+usernamerepo+"/releases/latest").content)
|
release = json.loads(
|
||||||
|
requests.get(
|
||||||
|
"https://api.github.com/repos/"+usernamerepo+"/releases/latest"
|
||||||
|
).content)
|
||||||
url = release["assets"][assetNumber]["browser_download_url"]
|
url = release["assets"][assetNumber]["browser_download_url"]
|
||||||
return url
|
return url
|
||||||
|
|
||||||
#Push text to output box
|
|
||||||
def outputbox(message):
|
def outputbox(message):
|
||||||
outputBox.configure(state='normal')
|
outputBox.configure(state='normal')
|
||||||
outputBox.insert('end', message)
|
outputBox.insert('end', message)
|
||||||
outputBox.see(tkinter.END)
|
outputBox.see(tkinter.END)
|
||||||
outputBox.configure(state='disabled')
|
outputBox.configure(state='disabled')
|
||||||
|
|
||||||
#Check if directory exists and has write permissions
|
|
||||||
def validateDirectory(directory):
|
def validateDirectory(directory):
|
||||||
try:
|
try:
|
||||||
directory = str(directory)
|
directory = str(directory)
|
||||||
@@ -91,31 +100,26 @@ def validateDirectory(directory):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
|
|
||||||
def un7zipper(_7za, zipfile, destination):
|
def un7zipper(_7za, zipfile, destination):
|
||||||
proc = Popen([_7za,"x", "-aoa", zipfile, '-o'+destination])
|
un7zipper = Popen([_7za, "x", "-aoa", zipfile, '-o'+destination])
|
||||||
|
un7zipper.wait()
|
||||||
ret_val = proc.wait()
|
|
||||||
|
|
||||||
while True:
|
|
||||||
if ret_val == 0:
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
|
|
||||||
# Clear outputBox
|
# Clear outputBox
|
||||||
outputBox.configure(state='normal')
|
outputBox.configure(state='normal')
|
||||||
outputBox.delete('1.0', tkinter.END)
|
outputBox.delete('1.0', tkinter.END)
|
||||||
outputBox.configure(state='disabled')
|
outputBox.configure(state='disabled')
|
||||||
|
|
||||||
sysname = platform.system()
|
|
||||||
# Locate 7z binary
|
# Locate 7z binary
|
||||||
|
sysname = platform.system()
|
||||||
_7za = os.path.join(sysname, '7za')
|
_7za = os.path.join(sysname, '7za')
|
||||||
_7z = None
|
_7z = None
|
||||||
if sysname in ["Darwin", "Linux"]:
|
if sysname in ["Darwin", "Linux"]:
|
||||||
@@ -124,24 +128,28 @@ def start():
|
|||||||
os.chmod(_7za, stat.S_IRWXU)
|
os.chmod(_7za, stat.S_IRWXU)
|
||||||
if sysname == "Windows":
|
if sysname == "Windows":
|
||||||
# Search for 7z in the 64-bit Windows Registry
|
# Search for 7z in the 64-bit Windows Registry
|
||||||
from winreg import OpenKey, QueryValueEx, HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_64KEY
|
import winreg
|
||||||
print('Searching for 7-Zip in the Windows registry...')
|
print('Searching for 7-Zip in the Windows registry...')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with OpenKey(HKEY_LOCAL_MACHINE, 'SOFTWARE\\7-Zip', 0, KEY_READ | KEY_WOW64_64KEY) as hkey:
|
with winreg.OpenKey(
|
||||||
_7z = os.path.join(QueryValueEx(hkey, 'Path')[0], '7z.exe')
|
winreg.HKEY_LOCAL_MACHINE,
|
||||||
|
'SOFTWARE\\7-Zip', 0, winreg.KEY_READ | winreg.KEY_WOW64_64KEY
|
||||||
|
) as hkey:
|
||||||
|
_7z = os.path.join(winreg.QueryValueEx(
|
||||||
|
hkey, 'Path')[0], '7z.exe')
|
||||||
|
|
||||||
if not os.path.exists(_7z):
|
if not os.path.exists(_7z):
|
||||||
raise WindowsError
|
raise WindowsError
|
||||||
|
|
||||||
_7za = _7z
|
_7za = _7z
|
||||||
except WindowsError:
|
except WindowsError:
|
||||||
# Search for 7z in the 32-bit Windows Registry
|
# Search for 7z in the 32-bit Windows Registry
|
||||||
print('Searching for 7-Zip in the 32-bit Windows registry...')
|
print('Searching for 7-Zip in the 32-bit Windows registry...')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with OpenKey(HKEY_LOCAL_MACHINE, 'SOFTWARE\\7-Zip') as hkey:
|
with winreg.OpenKey(
|
||||||
_7z = os.path.join(QueryValueEx(hkey, 'Path')[0], '7z.exe')
|
winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\7-Zip'
|
||||||
|
) as hkey:
|
||||||
|
_7z = os.path.join(winreg.QueryValueEx(hkey, 'Path')[0], '7z.exe')
|
||||||
|
|
||||||
if not os.path.exists(_7z):
|
if not os.path.exists(_7z):
|
||||||
raise WindowsError
|
raise WindowsError
|
||||||
@@ -155,8 +163,6 @@ def start():
|
|||||||
print("7-Zip found!")
|
print("7-Zip found!")
|
||||||
|
|
||||||
lineCounter = 0
|
lineCounter = 0
|
||||||
|
|
||||||
#Variables
|
|
||||||
directory = SDentry
|
directory = SDentry
|
||||||
if directory.endswith("\\") or directory.endswith("/"):
|
if directory.endswith("\\") or directory.endswith("/"):
|
||||||
directory = directory[:-1]
|
directory = directory[:-1]
|
||||||
@@ -165,7 +171,7 @@ def start():
|
|||||||
|
|
||||||
# Validate directory
|
# Validate directory
|
||||||
directoryValidated = validateDirectory(directory)
|
directoryValidated = validateDirectory(directory)
|
||||||
if directoryValidated == False:
|
if directoryValidated is False:
|
||||||
finalbackButton.configure(state='normal')
|
finalbackButton.configure(state='normal')
|
||||||
return
|
return
|
||||||
if dsiVersions.index(version) == 1:
|
if dsiVersions.index(version) == 1:
|
||||||
@@ -173,7 +179,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 path called "/lazy-dsi-file-downloader-tmp/"
|
||||||
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)
|
||||||
|
|
||||||
@@ -183,7 +189,7 @@ def start():
|
|||||||
Path(memoryPitLocation).mkdir(parents=True, exist_ok=True)
|
Path(memoryPitLocation).mkdir(parents=True, exist_ok=True)
|
||||||
outputbox("Downloading Memory Pit\n")
|
outputbox("Downloading Memory Pit\n")
|
||||||
downloadLocation = downloadFile(memoryPitDownload, memoryPitLocation)
|
downloadLocation = downloadFile(memoryPitDownload, memoryPitLocation)
|
||||||
if downloadLocation != None:
|
if downloadLocation is not None:
|
||||||
outputbox("Memory Pit Downloaded\n")
|
outputbox("Memory Pit Downloaded\n")
|
||||||
print("Memory Pit Downloaded")
|
print("Memory Pit Downloaded")
|
||||||
|
|
||||||
@@ -191,30 +197,24 @@ def start():
|
|||||||
# Download TWiLight Menu
|
# Download TWiLight Menu
|
||||||
outputbox("Downloading TWiLight Menu ++\n")
|
outputbox("Downloading TWiLight Menu ++\n")
|
||||||
TWLmenuLocation = downloadFile(getLatestGitHub('DS-Homebrew/TWiLightMenu', 1), cwdtemp)
|
TWLmenuLocation = downloadFile(getLatestGitHub('DS-Homebrew/TWiLightMenu', 1), cwdtemp)
|
||||||
if TWLmenuLocation != None:
|
if TWLmenuLocation is not None:
|
||||||
outputbox("TWiLight Menu ++ Downloaded\n")
|
outputbox("TWiLight Menu ++ Downloaded\n")
|
||||||
print("TWiLight Menu ++ Downloaded")
|
print("TWiLight Menu ++ Downloaded")
|
||||||
|
|
||||||
# Extract TWiLight Menu
|
# Extract TWiLight Menu
|
||||||
proc = Popen([_7za,"x", "-aoa", TWLmenuLocation, '-o'+cwdtemp, '_nds', 'hiya', 'roms','title', 'BOOT.NDS','snemul.cfg'])
|
proc = Popen([_7za,"x", "-aoa", TWLmenuLocation, '-o'+cwdtemp, '_nds', 'hiya', 'roms','title', 'BOOT.NDS','snemul.cfg'])
|
||||||
ret_val = proc.wait()
|
ret_val = proc.wait()
|
||||||
|
|
||||||
while True:
|
|
||||||
if ret_val == 0:
|
|
||||||
outputbox("TWiLight Menu ++ Extracted\n")
|
outputbox("TWiLight Menu ++ Extracted\n")
|
||||||
print("TWiLight Menu ++ Extracted to", cwdtemp)
|
print("TWiLight Menu ++ Extracted to", cwdtemp)
|
||||||
break
|
|
||||||
originalHash = hashcreator(cwdtemp + "BOOT.NDS")
|
originalHash = hashcreator(cwdtemp + "BOOT.NDS")
|
||||||
|
|
||||||
# Move TWiLight Menu
|
# Move TWiLight Menu
|
||||||
shutil.copy(cwdtemp + "BOOT.NDS", directory)
|
shutil.copy(cwdtemp + "BOOT.NDS", directory)
|
||||||
|
|
||||||
distutils.dir_util.copy_tree(cwdtemp + "_nds/", directory + "/_nds/")
|
distutils.dir_util.copy_tree(cwdtemp + "_nds/", directory + "/_nds/")
|
||||||
distutils.dir_util.copy_tree(cwdtemp + "hiya", directory + "/hiya/")
|
distutils.dir_util.copy_tree(cwdtemp + "hiya", directory + "/hiya/")
|
||||||
distutils.dir_util.copy_tree(cwdtemp + "title", directory + "/title/")
|
distutils.dir_util.copy_tree(cwdtemp + "title", directory + "/title/")
|
||||||
distutils.dir_util.copy_tree(cwdtemp + "roms", directory + "/roms/")
|
distutils.dir_util.copy_tree(cwdtemp + "roms", directory + "/roms/")
|
||||||
|
|
||||||
|
|
||||||
# Some Homebrew write to the _nds folder so it is better to clear it first
|
# Some Homebrew write to the _nds folder so it is better to clear it first
|
||||||
shutil.rmtree(cwdtemp +"_nds/")
|
shutil.rmtree(cwdtemp +"_nds/")
|
||||||
Path(cwdtemp + "_nds/").mkdir(parents=True, exist_ok=True)
|
Path(cwdtemp + "_nds/").mkdir(parents=True, exist_ok=True)
|
||||||
@@ -222,22 +222,19 @@ def start():
|
|||||||
if originalHash == comparedHash:
|
if originalHash == comparedHash:
|
||||||
print("TWiLight Menu ++ placed in", directory)
|
print("TWiLight Menu ++ placed in", directory)
|
||||||
outputbox("TWiLight Menu ++ placed on SD \n")
|
outputbox("TWiLight Menu ++ placed on SD \n")
|
||||||
|
|
||||||
|
|
||||||
# Download DeadSkullzJr's Cheat Database
|
# Download DeadSkullzJr's Cheat Database
|
||||||
Path(directory + "/_nds/TWiLightMenu/extras/").mkdir(parents=True, exist_ok=True)
|
Path(directory + "/_nds/TWiLightMenu/extras/").mkdir(parents=True, exist_ok=True)
|
||||||
outputbox("Downloading DeadSkullzJr's Cheat database\n")
|
outputbox("Downloading DeadSkullzJr's Cheat database\n")
|
||||||
downloadLocation = downloadFile('https://bitbucket.org/DeadSkullzJr/nds-cheat-databases/raw/933c375545d3ff90854d1e210dcf4b3b31d9d585/Cheats/usrcheat.dat', directory + "/_nds/TWiLightMenu/extras/")
|
downloadLocation = downloadFile('https://bitbucket.org/DeadSkullzJr/nds-cheat-databases/raw/933c375545d3ff90854d1e210dcf4b3b31d9d585/Cheats/usrcheat.dat', directory + "/_nds/TWiLightMenu/extras/")
|
||||||
if downloadLocation != None:
|
if downloadLocation is not None:
|
||||||
print("DeadSkullzJr's Cheat Database downloaded")
|
print("DeadSkullzJr's Cheat Database downloaded")
|
||||||
outputbox("DeadSkullzJr's Cheat Database downloaded\n")
|
outputbox("DeadSkullzJr's Cheat Database downloaded\n")
|
||||||
|
|
||||||
|
|
||||||
if downloaddumptool.get() == 1:
|
if downloaddumptool.get() == 1:
|
||||||
# Download dumpTool
|
# Download dumpTool
|
||||||
outputbox("Downloading dumpTool\n")
|
outputbox("Downloading dumpTool\n")
|
||||||
downloadLocation = downloadFile(getLatestGitHub('zoogie/dumpTool', 0), directory)
|
downloadLocation = downloadFile(getLatestGitHub('zoogie/dumpTool', 0), directory)
|
||||||
if downloadLocation != None:
|
if downloadLocation is not None:
|
||||||
print("dumpTool downloaded")
|
print("dumpTool downloaded")
|
||||||
outputbox("dumpTool Downloaded\n")
|
outputbox("dumpTool Downloaded\n")
|
||||||
lineCounter = lineCounter + 1
|
lineCounter = lineCounter + 1
|
||||||
@@ -247,13 +244,13 @@ def start():
|
|||||||
url = "https://web.archive.org/web/20210207235625if_/https://problemkaputt.de/unlaunch.zip"
|
url = "https://web.archive.org/web/20210207235625if_/https://problemkaputt.de/unlaunch.zip"
|
||||||
outputbox("Downloading Unlaunch\n")
|
outputbox("Downloading Unlaunch\n")
|
||||||
unlaunchLocation = downloadFile(url, cwdtemp)
|
unlaunchLocation = downloadFile(url, cwdtemp)
|
||||||
if unlaunchLocation != None:
|
if unlaunchLocation is not None:
|
||||||
print("Unlaunch Downloaded")
|
print("Unlaunch Downloaded")
|
||||||
outputbox("Unlaunch Downloaded\n")
|
outputbox("Unlaunch Downloaded\n")
|
||||||
lineCounter = lineCounter + 1
|
lineCounter = lineCounter + 1
|
||||||
# Extract Unlaunch
|
# Extract Unlaunch
|
||||||
unzipper(unlaunchLocation,directory)
|
unzipper(unlaunchLocation, irectory)
|
||||||
|
print("Unlaunch Extracted")
|
||||||
|
|
||||||
# Creates roms/nds if it does not exist
|
# Creates roms/nds if it does not exist
|
||||||
roms = directory + "/roms/nds/"
|
roms = directory + "/roms/nds/"
|
||||||
@@ -263,19 +260,15 @@ def start():
|
|||||||
# Download GodMode9i
|
# Download GodMode9i
|
||||||
outputbox("Downloading GodMode9i\n")
|
outputbox("Downloading GodMode9i\n")
|
||||||
downloadLocation = downloadFile(getLatestGitHub('DS-Homebrew/GodMode9i', 0), cwdtemp)
|
downloadLocation = downloadFile(getLatestGitHub('DS-Homebrew/GodMode9i', 0), cwdtemp)
|
||||||
if downloadLocation != None:
|
if downloadLocation is not None:
|
||||||
print("GodMode9i downloaded")
|
print("GodMode9i downloaded")
|
||||||
outputbox("GodMode9i Downloaded\n")
|
outputbox("GodMode9i Downloaded\n")
|
||||||
lineCounter = lineCounter + 1
|
lineCounter = lineCounter + 1
|
||||||
# Extract TWiLight Menu
|
# Extract TWiLight Menu
|
||||||
proc = Popen([_7za,"x", "-aoa", downloadLocation, '-o'+roms, 'GodMode9i.nds'])
|
proc = Popen([_7za,"x", "-aoa", downloadLocation, '-o'+roms, 'GodMode9i.nds'])
|
||||||
ret_val = proc.wait()
|
ret_val = proc.wait()
|
||||||
|
|
||||||
while True:
|
|
||||||
if ret_val == 0:
|
|
||||||
outputbox("GodMode9i Extracted\n")
|
outputbox("GodMode9i Extracted\n")
|
||||||
print("GodMode9i Extracted to", roms)
|
print("GodMode9i Extracted to", roms)
|
||||||
break
|
|
||||||
|
|
||||||
if updateHiyaCFW.get() == 1:
|
if updateHiyaCFW.get() == 1:
|
||||||
# Check if old hiyaCFW insallation exists
|
# Check if old hiyaCFW insallation exists
|
||||||
@@ -284,25 +277,22 @@ def start():
|
|||||||
outputbox("hiyaCFW found...\n")
|
outputbox("hiyaCFW found...\n")
|
||||||
outputbox("Downloading latest...\n")
|
outputbox("Downloading latest...\n")
|
||||||
downloadLocation = downloadFile(getLatestGitHub("RocketRobz/hiyaCFW", 0), cwdtemp)
|
downloadLocation = downloadFile(getLatestGitHub("RocketRobz/hiyaCFW", 0), cwdtemp)
|
||||||
if downloadLocation != None:
|
if downloadLocation is not None:
|
||||||
outputbox("hiyaCFW.7z downloaded\n")
|
outputbox("hiyaCFW.7z downloaded\n")
|
||||||
os.remove(directory+"/hiya.dsi")
|
os.remove(directory+"/hiya.dsi")
|
||||||
proc = Popen([_7za,"x","-aoa",downloadLocation, "-o"+directory,"for SDNAND SD card\hiya.dsi"])
|
proc = Popen([_7za,"x","-aoa",downloadLocation, "-o"+directory,"for SDNAND SD card\hiya.dsi"])
|
||||||
ret_val = proc
|
ret_val = proc.wait()
|
||||||
shutil.move(directory + "/for SDNAND SD card/hiya.dsi", directory + "/hiya.dsi")
|
shutil.move(directory + "/for SDNAND SD card/hiya.dsi", directory + "/hiya.dsi")
|
||||||
shutil.rmtree(directory + "/for SDNAND SD card/")
|
shutil.rmtree(directory + "/for SDNAND SD card/")
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
outputbox("hiya.dsi was not found\n")
|
outputbox("hiya.dsi was not found\n")
|
||||||
outputbox("Please run the hiyaCFW helper first")
|
outputbox("Please run the hiyaCFW helper first")
|
||||||
|
|
||||||
|
# Download and extract extra homebrew
|
||||||
outputbox("Downloading other homebrew\n")
|
outputbox("Downloading other homebrew\n")
|
||||||
lineCounter = lineCounter + 1
|
lineCounter = lineCounter + 1
|
||||||
print("Downloading other homebrew...")
|
print("Downloading other homebrew...")
|
||||||
|
|
||||||
|
|
||||||
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"])
|
||||||
@@ -317,13 +307,13 @@ def start():
|
|||||||
outputbox("Downloaded "+item["title"]+'\n')
|
outputbox("Downloaded "+item["title"]+'\n')
|
||||||
elif item["extension"] == "zip":
|
elif item["extension"] == "zip":
|
||||||
downloadLocation = downloadFile(downloadlink, cwdtemp)
|
downloadLocation = downloadFile(downloadlink, cwdtemp)
|
||||||
if downloadLocation != None:
|
if downloadLocation is not None:
|
||||||
if item["location"]["roms"] == "all":
|
if item["location"]["roms"] == "all":
|
||||||
unzipper(downloadLocation, roms)
|
unzipper(downloadLocation, roms)
|
||||||
outputbox("Downloaded "+item["title"]+'\n')
|
outputbox("Downloaded "+item["title"]+'\n')
|
||||||
elif item["extension"] == "7z":
|
elif item["extension"] == "7z":
|
||||||
downloadLocation = downloadFile(downloadlink, cwdtemp)
|
downloadLocation = downloadFile(downloadlink, cwdtemp)
|
||||||
if downloadLocation != None:
|
if downloadLocation is not None:
|
||||||
if item["location"]["roms"] == "all":
|
if item["location"]["roms"] == "all":
|
||||||
un7zipper(_7za, downloadLocation, roms)
|
un7zipper(_7za, downloadLocation, roms)
|
||||||
outputbox("Downloaded "+item["title"]+'\n')
|
outputbox("Downloaded "+item["title"]+'\n')
|
||||||
@@ -335,23 +325,20 @@ def start():
|
|||||||
if "roms" in item["location"]:
|
if "roms" in item["location"]:
|
||||||
shutil.copy(cwdtemp+item["location"]["roms"], roms)
|
shutil.copy(cwdtemp+item["location"]["roms"], roms)
|
||||||
outputbox("Downloaded "+item["title"]+'\n')
|
outputbox("Downloaded "+item["title"]+'\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Delete tmp folder
|
# Delete tmp folder
|
||||||
shutil.rmtree(cwdtemp)
|
shutil.rmtree(cwdtemp)
|
||||||
|
|
||||||
# Restore button access
|
# Restore button access
|
||||||
finalnextButton.config(state="normal")
|
finalnextButton.config(state="normal")
|
||||||
window.protocol("WM_DELETE_WINDOW", lambda: closeButtonPress(window))
|
window.protocol("WM_DELETE_WINDOW", lambda: closeButtonPress(window))
|
||||||
|
|
||||||
print("Done!")
|
print("Done!")
|
||||||
outputbox("Done!\n")
|
outputbox("Done!\n")
|
||||||
outputbox("Press the Finish button to continue... \n")
|
outputbox("Press the Finish button to continue... \n")
|
||||||
|
|
||||||
|
|
||||||
def chooseDir(source, SDentry):
|
def chooseDir(source, SDentry):
|
||||||
source.sourceFolder = filedialog.askdirectory(parent=source, initialdir= "/", title='Please select the root directory of your SD card')
|
source.sourceFolder = filedialog.askdirectory(
|
||||||
|
parent=source, initialdir="/",
|
||||||
|
title='Please select the root 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)
|
||||||
|
|
||||||
@@ -360,6 +347,7 @@ def okButtonPress(self,source):
|
|||||||
self.destroy()
|
self.destroy()
|
||||||
source.deiconify()
|
source.deiconify()
|
||||||
|
|
||||||
|
|
||||||
def extraHomebrew(source):
|
def extraHomebrew(source):
|
||||||
homebrewWindow = tkinter.Toplevel(source)
|
homebrewWindow = tkinter.Toplevel(source)
|
||||||
homebrewWindow.config(bg="#f0f0f0")
|
homebrewWindow.config(bg="#f0f0f0")
|
||||||
@@ -368,46 +356,43 @@ def extraHomebrew(source):
|
|||||||
homebrewWindowLabel.pack(anchor="w")
|
homebrewWindowLabel.pack(anchor="w")
|
||||||
homebrewWindowLabel2 = tkinter.Label(homebrewWindow, text="Select additional homebrew for download then press OK", font=(bodyFont), bg="#f0f0f0", fg="#000000")
|
homebrewWindowLabel2 = tkinter.Label(homebrewWindow, text="Select additional homebrew for download then press OK", font=(bodyFont), bg="#f0f0f0", fg="#000000")
|
||||||
homebrewWindowLabel2.pack(anchor="w")
|
homebrewWindowLabel2.pack(anchor="w")
|
||||||
|
|
||||||
vscrollbar = tkinter.Scrollbar(homebrewWindow)
|
vscrollbar = tkinter.Scrollbar(homebrewWindow)
|
||||||
canvas = tkinter.Canvas(homebrewWindow, yscrollcommand=vscrollbar.set)
|
canvas = tkinter.Canvas(homebrewWindow, yscrollcommand=vscrollbar.set)
|
||||||
canvas.config(bg="#f0f0f0")
|
canvas.config(bg="#f0f0f0")
|
||||||
vscrollbar.config(command=canvas.yview)
|
vscrollbar.config(command=canvas.yview)
|
||||||
vscrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
|
vscrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
|
||||||
|
|
||||||
homebrewFrame = tkinter.Frame(canvas)
|
homebrewFrame = tkinter.Frame(canvas)
|
||||||
homebrewFrame.configure(bg="#f0f0f0")
|
homebrewFrame.configure(bg="#f0f0f0")
|
||||||
|
|
||||||
homebrewWindow.title("Homebrew List")
|
homebrewWindow.title("Homebrew List")
|
||||||
homebrewWindow.resizable(0, 0)
|
homebrewWindow.resizable(0, 0)
|
||||||
canvas.pack(side="left", fill="both", expand=True)
|
canvas.pack(side="left", fill="both", expand=True)
|
||||||
canvas.create_window(0, 0, window=homebrewFrame, anchor="n")
|
canvas.create_window(0, 0, window=homebrewFrame, anchor="n")
|
||||||
for count, x in enumerate(homebrewDB):
|
for count, x in enumerate(homebrewDB):
|
||||||
l = tkinter.Checkbutton(homebrewFrame, text=x["title"] + " by " + x["author"],font=(bigListFont), variable=homebrewList[count],bg="#f0f0f0",fg="#000000")
|
homebrewListMenu = tkinter.Checkbutton(homebrewFrame, text=x["title"] + " by " + x["author"], font=(bigListFont), variable=homebrewList[count], bg="#f0f0f0", fg="#000000")
|
||||||
l.config(selectcolor="#F0F0F0")
|
homebrewListMenu.config(selectcolor="#F0F0F0")
|
||||||
l.pack(anchor = "w")
|
homebrewListMenu.pack(anchor = "w")
|
||||||
|
|
||||||
frame = tkinter.ttk.Frame(homebrewWindow, relief=tkinter.RAISED, borderwidth=1)
|
frame = tkinter.ttk.Frame(homebrewWindow, relief=tkinter.RAISED, borderwidth=1)
|
||||||
frame.pack(fill=tkinter.BOTH, expand=True)
|
frame.pack(fill=tkinter.BOTH, expand=True)
|
||||||
|
|
||||||
|
|
||||||
okButton = Button(homebrewWindow, text = "OK", font=(buttonFont), command=lambda: okButtonPress(homebrewWindow,source), bg="#f0f0f0", fg="#000000")
|
okButton = Button(homebrewWindow, text = "OK", font=(buttonFont), command=lambda: okButtonPress(homebrewWindow,source), bg="#f0f0f0", fg="#000000")
|
||||||
okButton.pack(side=tkinter.RIGHT, padx=5, pady=5)
|
okButton.pack(side=tkinter.RIGHT, padx=5, pady=5)
|
||||||
homebrewWindow.update()
|
homebrewWindow.update()
|
||||||
canvas.config(scrollregion=canvas.bbox("all"))
|
canvas.config(scrollregion=canvas.bbox("all"))
|
||||||
|
|
||||||
homebrewWindow.protocol("WM_DELETE_WINDOW", lambda: okButtonPress(homebrewWindow, source))
|
homebrewWindow.protocol("WM_DELETE_WINDOW", lambda: okButtonPress(homebrewWindow, source))
|
||||||
|
|
||||||
|
|
||||||
def closeButtonPress(source):
|
def closeButtonPress(source):
|
||||||
source.destroy()
|
source.destroy()
|
||||||
root.destroy()
|
root.destroy()
|
||||||
|
|
||||||
|
|
||||||
def nextWindow(windownumbertosummon):
|
def nextWindow(windownumbertosummon):
|
||||||
globals()["summonWindow"+windownumbertosummon]
|
globals()["summonWindow"+windownumbertosummon]
|
||||||
|
|
||||||
|
|
||||||
def donothing():
|
def donothing():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def summonWindow0():
|
def summonWindow0():
|
||||||
window.title("Lazy DSi file Downloader")
|
window.title("Lazy DSi file Downloader")
|
||||||
window.resizable(0, 0)
|
window.resizable(0, 0)
|
||||||
@@ -420,16 +405,13 @@ def summonWindow0():
|
|||||||
bottomFrame = tkinter.Frame(window)
|
bottomFrame = tkinter.Frame(window)
|
||||||
bottomFrame.pack(side=tkinter.BOTTOM, fill=tkinter.X, padx=5)
|
bottomFrame.pack(side=tkinter.BOTTOM, fill=tkinter.X, padx=5)
|
||||||
bottomFrame.option_add("*Background", backgroundColour)
|
bottomFrame.option_add("*Background", backgroundColour)
|
||||||
first = tkinter.Label(topFrame, text="Welcome to the Lazy DSi File Downloader", font=(titleFont), fg=foregroundColour)
|
first = tkinter.Label(topFrame, text="Lazy DSi File Downloader", font=(titleFont), fg=foregroundColour)
|
||||||
first.grid(column=0, row=0, sticky="w", padx=5)
|
first.grid(column=0, row=0, sticky="w", padx=5)
|
||||||
|
|
||||||
bulletpoints = [
|
bulletpoints = [
|
||||||
"This is an application made by Your Kalamity that downloads and place files for homebrew'ing your Nintendo DSi in the correct location. If you have already installed homebrew, this can also update the one you have.",
|
"This is an application made by Your Kalamity that downloads and place files for homebrew'ing your Nintendo DSi in the correct location. If you have already installed homebrew, this can also update the one you have.",
|
||||||
"This is to be used in conjunction with the Nintendo DSi Modding guide by NightScript and emiyl",
|
"This is to be used in conjunction with the Nintendo DSi Modding guide by NightScript, emiyl and the rest of the community.",
|
||||||
"Check it out here: https://dsi.cfw.guide/",
|
"Check it out here: https://dsi.cfw.guide/",
|
||||||
"By using this application, you do not need to follow any of the 'Preparing SD card' steps.",
|
"By using this application, you don't need to follow any of the 'Preparing SD card' steps.",
|
||||||
"This application is to be given for free. If you have paid to receive this, contact the person that sold you this application; you have been scammed.",
|
|
||||||
"You may use any part of this application for your own purposes as long as credit is given.",
|
|
||||||
"Please proceed by hitting the 'Next' button"
|
"Please proceed by hitting the 'Next' button"
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -479,7 +461,6 @@ def summonWindow1():
|
|||||||
|
|
||||||
|
|
||||||
def summonWindow2():
|
def summonWindow2():
|
||||||
|
|
||||||
topFrame = tkinter.Frame(window)
|
topFrame = tkinter.Frame(window)
|
||||||
topFrame.pack(expand=True, fill=tkinter.BOTH, padx=5)
|
topFrame.pack(expand=True, fill=tkinter.BOTH, padx=5)
|
||||||
topFrame.option_add("*Background", backgroundColour)
|
topFrame.option_add("*Background", backgroundColour)
|
||||||
@@ -510,6 +491,7 @@ def summonWindow2():
|
|||||||
nextButton.pack(side=tkinter.RIGHT, padx=5, pady=5)
|
nextButton.pack(side=tkinter.RIGHT, padx=5, pady=5)
|
||||||
window.protocol("WM_DELETE_WINDOW",lambda:closeButtonPress(window))
|
window.protocol("WM_DELETE_WINDOW",lambda:closeButtonPress(window))
|
||||||
|
|
||||||
|
|
||||||
def summonWindow3():
|
def summonWindow3():
|
||||||
topFrame = tkinter.Frame(window)
|
topFrame = tkinter.Frame(window)
|
||||||
topFrame.pack(expand=True, fill=tkinter.BOTH,padx=5)
|
topFrame.pack(expand=True, fill=tkinter.BOTH,padx=5)
|
||||||
@@ -533,10 +515,12 @@ def summonWindow3():
|
|||||||
nextButton.pack(side=tkinter.RIGHT, padx=5, pady=5)
|
nextButton.pack(side=tkinter.RIGHT, padx=5, pady=5)
|
||||||
window.protocol("WM_DELETE_WINDOW",lambda:closeButtonPress(window))
|
window.protocol("WM_DELETE_WINDOW",lambda:closeButtonPress(window))
|
||||||
|
|
||||||
|
|
||||||
def globalify(value):
|
def globalify(value):
|
||||||
global SDentry
|
global SDentry
|
||||||
SDentry = value
|
SDentry = value
|
||||||
|
|
||||||
|
|
||||||
def summonWindow4():
|
def summonWindow4():
|
||||||
startThread = threading.Thread(target=start, daemon=True)
|
startThread = threading.Thread(target=start, daemon=True)
|
||||||
topFrame = tkinter.Frame(window)
|
topFrame = tkinter.Frame(window)
|
||||||
@@ -561,8 +545,8 @@ def summonWindow4():
|
|||||||
finalnextButton.pack(side=tkinter.RIGHT, padx=5, pady=5)
|
finalnextButton.pack(side=tkinter.RIGHT, padx=5, pady=5)
|
||||||
window.protocol("WM_DELETE_WINDOW",lambda:donothing)
|
window.protocol("WM_DELETE_WINDOW",lambda:donothing)
|
||||||
|
|
||||||
def summonWindow5():
|
|
||||||
|
|
||||||
|
def summonWindow5():
|
||||||
topFrame = tkinter.Frame(window)
|
topFrame = tkinter.Frame(window)
|
||||||
topFrame.pack(expand=True, fill=tkinter.BOTH,padx=5)
|
topFrame.pack(expand=True, fill=tkinter.BOTH,padx=5)
|
||||||
topFrame.option_add("*Background", backgroundColour)
|
topFrame.option_add("*Background", backgroundColour)
|
||||||
@@ -592,11 +576,9 @@ def summonWindow5():
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
if(sys.version_info.major < 3):
|
if(sys.version_info.major < 3):
|
||||||
print("This program will ONLY work on Python 3 and above")
|
print("This program will ONLY work on Python 3 and above")
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
|
os.chdir(os.path.dirname(os.path.abspath(sys.argv[0])))
|
||||||
|
|
||||||
root = tkinter.Tk()
|
root = tkinter.Tk()
|
||||||
@@ -609,7 +591,6 @@ if __name__ == "__main__":
|
|||||||
for x in homebrewDB:
|
for x in homebrewDB:
|
||||||
homebrewList.append(tkinter.IntVar())
|
homebrewList.append(tkinter.IntVar())
|
||||||
|
|
||||||
|
|
||||||
# TKinter Vars
|
# TKinter Vars
|
||||||
downloadmemorypit = tkinter.IntVar(value=1)
|
downloadmemorypit = tkinter.IntVar(value=1)
|
||||||
firmwareVersion = tkinter.StringVar()
|
firmwareVersion = tkinter.StringVar()
|
||||||
@@ -631,7 +612,6 @@ if __name__ == "__main__":
|
|||||||
size=11,
|
size=11,
|
||||||
slant="italic"
|
slant="italic"
|
||||||
)
|
)
|
||||||
|
|
||||||
bodyFont = tkinter.font.Font(
|
bodyFont = tkinter.font.Font(
|
||||||
family="Segoe UI",
|
family="Segoe UI",
|
||||||
underline=False,
|
underline=False,
|
||||||
@@ -643,30 +623,26 @@ if __name__ == "__main__":
|
|||||||
size=11,
|
size=11,
|
||||||
weight="bold"
|
weight="bold"
|
||||||
)
|
)
|
||||||
|
|
||||||
bigListFont = tkinter.font.Font(
|
bigListFont = tkinter.font.Font(
|
||||||
family="Segoe UI",
|
family="Segoe UI",
|
||||||
underline=False,
|
underline=False,
|
||||||
size=9
|
size=9
|
||||||
)
|
)
|
||||||
|
|
||||||
paragraphFont = tkinter.font.Font(
|
paragraphFont = tkinter.font.Font(
|
||||||
family="Segoe UI",
|
family="Segoe UI",
|
||||||
size=10
|
size=10
|
||||||
)
|
)
|
||||||
|
|
||||||
if platform.system() == "Darwin": #Why is macOS so difficult...
|
if platform.system() == "Darwin":
|
||||||
from tkmacosx import Button
|
from tkmacosx import Button
|
||||||
backgroundColour = "#f0f0f0" #How dull and boring
|
backgroundColour = "#f0f0f0"
|
||||||
foregroundColour = "black"
|
foregroundColour = "black"
|
||||||
buttonColour = "#f0f0f0"
|
buttonColour = "#f0f0f0"
|
||||||
backButtonColour = "#f0f0f0"
|
backButtonColour = "#f0f0f0"
|
||||||
nextButtonColour = "#f0f0f0"
|
nextButtonColour = "#f0f0f0"
|
||||||
button_width = 80
|
button_width = 80
|
||||||
folder_width = 250
|
folder_width = 250
|
||||||
|
else:
|
||||||
|
|
||||||
else: #Non Jeve Stobs worshippers
|
|
||||||
from tkinter import Button
|
from tkinter import Button
|
||||||
backgroundColour = "#252a34"
|
backgroundColour = "#252a34"
|
||||||
foregroundColour = "white"
|
foregroundColour = "white"
|
||||||
|
|||||||
Reference in New Issue
Block a user