diff --git a/contrib/PC/MagicMemoryCreator/main.py b/contrib/PC/MagicMemoryCreator/main.py index 6031df34..29d9c13e 100755 --- a/contrib/PC/MagicMemoryCreator/main.py +++ b/contrib/PC/MagicMemoryCreator/main.py @@ -1,15 +1,16 @@ #!/usr/bin/env python3 import tkinter as tk -import platform -import os -import time -import sys import ctypes import glob +import os +import platform import requests -import subprocess import shutil +import subprocess +import sys +import time import msipl_installer +import urllib3; urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) from zipfile import ZipFile if platform.system().lower() != 'linux' and platform.system().lower() != 'windows' and platform.system().lower() != 'darwin': @@ -104,28 +105,30 @@ def run() -> None: b['text'] = "Please Wait..." global go - # Download pspdecrypt from John if platform.system() == 'Linux': - resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-linux.zip', verify=False) + resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-linux.zip', timeout=10, verify=False) with open('pspdecrypt-1.0-linux.zip', 'wb') as f: f.write(resp.content) + resp.close() with ZipFile('pspdecrypt-1.0-linux.zip', 'r') as zObject: zObject.extractall(path=f'{os.getcwd()}/') os.system('oschmod 755 pspdecrypt') x['state'] = "normal" elif platform.system() == 'Windows': - resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-windows.zip', verify=False) + resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-windows.zip', timeout=10, verify=False) with open('pspdecrypt-1.0-windows.zip', 'wb') as f: f.write(resp.content) + resp.close() with ZipFile('pspdecrypt-1.0-windows.zip', 'r') as zObject: zObject.extractall(path=f'{os.getcwd()}\\') os.system('oschmod 755 pspdecrypt.exe') x['state'] = "normal" elif platform.system() == 'Darwin': - resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-macos.zip', verify=False) + resp = requests.get('https://github.com/John-K/pspdecrypt/releases/download/1.0/pspdecrypt-1.0-macos.zip', timeout=10, verify=False) with open('pspdecrypt-1.0-macos.zip', 'wb') as f: f.write(resp.content) + resp.close() with ZipFile('pspdecrypt-1.0-macos.zip', 'r') as zObject: zObject.extractall(path=f'{os.getcwd()}/') os.system('oschmod 755 pspdecrypt') @@ -136,13 +139,21 @@ def run() -> None: # Download 6.61 OFW if go: - resp = requests.get('http://du01.psp.update.playstation.org/update/psp/image2/us/2014_1212_fd0f7d0798b4f6e6d32ef95836740527/EBOOT.PBP', verify=False) - with open('661_GO.PBP', 'wb') as f: - f.write(resp.content) + resp = requests.get('http://du01.psp.update.playstation.org/update/psp/image2/us/2014_1212_fd0f7d0798b4f6e6d32ef95836740527/EBOOT.PBP', timeout=10, verify=False) + if resp: + with open('661_GO.PBP', 'wb') as f: + f.write(resp.content) + resp.close() + else: + print(resp.status_code) else: - resp = requests.get('http://du01.psp.update.playstation.org/update/psp/image/us/2014_1212_6be8878f475ac5b1a499b95ab2f7d301/EBOOT.PBP', verify=False) - with open('661.PBP', 'wb') as f: - f.write(resp.content) + resp = requests.get('http://du01.psp.update.playstation.org/update/psp/image/us/2014_1212_6be8878f475ac5b1a499b95ab2f7d301/EBOOT.PBP', timeout=10, verify=False) + if resp: + with open('661.PBP', 'wb') as f: + f.write(resp.content) + resp.close() + else: + print(resp.status_code) if platform.system() == 'Linux' or platform.system() == 'Darwin': if go: diff --git a/contrib/PC/MagicMemoryCreator/msipl_installer.py b/contrib/PC/MagicMemoryCreator/msipl_installer.py index 72a780f3..92c05af0 100755 --- a/contrib/PC/MagicMemoryCreator/msipl_installer.py +++ b/contrib/PC/MagicMemoryCreator/msipl_installer.py @@ -1,11 +1,12 @@ +#!/usr/bin/env python3 import argparse -import struct +import math import os -import time import platform -import math -import subprocess import re +import struct +import subprocess +import time is_windows = os.name == 'nt' is_macos = platform.system() == 'Darwin' @@ -54,7 +55,6 @@ def __init__(self, data): def main(args): - if is_windows: diskID = f'\\\\.\\PHYSICALDRIVE{args.pdisk}' diff --git a/contrib/PC/MagicMemoryCreator/prep_windows.bat b/contrib/PC/MagicMemoryCreator/prep_windows.bat new file mode 100644 index 00000000..1db7e0ef --- /dev/null +++ b/contrib/PC/MagicMemoryCreator/prep_windows.bat @@ -0,0 +1,2 @@ +@echo off +python.exe -m pip install -r requirements.txt \ No newline at end of file diff --git a/contrib/PC/MagicMemoryCreator/requirements.txt b/contrib/PC/MagicMemoryCreator/requirements.txt index 0e0c401a..f454a1b2 100644 --- a/contrib/PC/MagicMemoryCreator/requirements.txt +++ b/contrib/PC/MagicMemoryCreator/requirements.txt @@ -1,3 +1,4 @@ oschmod==0.3.12 -wmi==1.5.1; sys_platform == 'Windows' +psutil==5.9.8; sys_platform == 'win32' requests==2.31.0 +wmi==1.5.1; sys_platform == 'win32' diff --git a/contrib/PC/MagicMemoryCreator/run_windows.bat b/contrib/PC/MagicMemoryCreator/run_windows.bat new file mode 100644 index 00000000..d9c3db24 --- /dev/null +++ b/contrib/PC/MagicMemoryCreator/run_windows.bat @@ -0,0 +1,10 @@ +@echo off +fltmc >nul 2>&1 || ( + echo. + echo Run as Admin! + echo. + pause + goto :eof +) +cd /d %~dp0 +pythonw.exe main.py \ No newline at end of file diff --git a/contrib/PC/MagicMemoryCreator/run_windows_debug.bat b/contrib/PC/MagicMemoryCreator/run_windows_debug.bat new file mode 100644 index 00000000..9d4f8652 --- /dev/null +++ b/contrib/PC/MagicMemoryCreator/run_windows_debug.bat @@ -0,0 +1,11 @@ +@echo off +fltmc >nul 2>&1 || ( + echo. + echo Run as Admin! + echo. + pause + goto :eof +) +cd /d %~dp0 +python.exe main.py +pause \ No newline at end of file