From 9e0494b70cca8d46f527cd1f0f2c6fadfca1f3e4 Mon Sep 17 00:00:00 2001 From: bamhm182 Date: Fri, 17 May 2019 18:11:50 -0500 Subject: [PATCH] Added Linux Support --- .idea/workspace.xml | 119 +++++++---------------- FinTrinity.py | 20 ++-- classes/Utils.py | 19 +++- classes/__pycache__/Game.cpython-37.pyc | Bin 1268 -> 1268 bytes classes/__pycache__/User.cpython-37.pyc | Bin 2378 -> 2378 bytes classes/__pycache__/Utils.cpython-37.pyc | Bin 2687 -> 3202 bytes 6 files changed, 66 insertions(+), 92 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 29a960b..abbae25 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -19,8 +19,8 @@ - - + + @@ -28,19 +28,10 @@ - - - - - - - - - - + @@ -50,7 +41,7 @@ - + @@ -61,7 +52,7 @@ - + @@ -73,7 +64,7 @@ - + @@ -82,8 +73,8 @@ - - + + @@ -91,31 +82,10 @@ - - - - - - - - - - - - - - - - - - - - - - + @@ -150,6 +120,7 @@ print( read_re datetime + down utils.make_dir @@ -394,9 +365,9 @@ + - @@ -422,14 +393,15 @@ + - - + @@ -441,7 +413,7 @@ - + @@ -500,42 +472,40 @@ - + + + - - - - - - - - - - + + + - + - - - - + + + + + + + - + @@ -545,39 +515,22 @@ - + - + - - - - - - - - - - - - - - - - - - - + + @@ -586,8 +539,8 @@ - - + + diff --git a/FinTrinity.py b/FinTrinity.py index 3cad39c..33ca5b2 100644 --- a/FinTrinity.py +++ b/FinTrinity.py @@ -20,14 +20,17 @@ def __init__(self): def read_config(self): try: + username = None + account = None + if platform.uname().system == "Windows": self.apps_path = Path(Utils.read_hkcu(r"Software\codestation\qcma", 'appsPath')) / 'PGAME' account = Utils.read_hkcu(r"Software\codestation\qcma", 'lastAccountId') username = Utils.read_hkcu(r"Software\codestation\qcma", 'lastOnlineId') elif platform.uname().system == "Linux": - self.apps_path = Path(Utils.read_conf('Linux', 'appsPath')) - account = Utils.read_conf('Linux', 'lastAccountId') - username = Utils.read_conf('Linux', 'lastOnlineId') + self.apps_path = Path(Utils.read_conf('appsPath')) / 'PGAME' + account = Utils.read_conf('lastAccountId') + username = Utils.read_conf('lastOnlineId') if not os.path.exists(self.apps_path): print(f"{self.apps_path} does not exist. Please ensure you have run QCMA and backed up your game.") @@ -68,10 +71,15 @@ def backup_game(self): def download_dependencies(self): print(f"Downloading and Extracting Dependencies") + psvimgtools = None + if platform.uname().system == "Windows": + psvimgtools = "https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-win64.zip" + elif platform.uname().system == "Linux": + psvimgtools = "https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-linux64.zip" + Utils.download('https://github.com/TheOfficialFloW/Trinity/releases/download/v1.0/PBOOT.PBP', self.working_dir) - Utils.download('https://github.com/yifanlu/psvimgtools/releases/download/v0.1/psvimgtools-0.1-win64.zip', - self.working_dir) - Utils.extract(self.working_dir / 'psvimgtools-0.1-win64.zip', self.decrypt_dir) + Utils.download(psvimgtools, self.working_dir) + Utils.extract(self.working_dir / psvimgtools.split("/")[-1], self.decrypt_dir) def hack(self): print(f"Applying Trinity Hack:\n\n\n") diff --git a/classes/Utils.py b/classes/Utils.py index f01ac81..87b6140 100644 --- a/classes/Utils.py +++ b/classes/Utils.py @@ -1,17 +1,20 @@ import os import shutil -import winreg from urllib import request from zipfile import ZipFile import datetime from pathlib import Path import sys +import platform +import stat def decrypt_game(key, src, pboot, game_id): print("Decrypting:\n") os.chdir(src) - command = f'psvimg-extract -K {key} game/game.psvimg game_dec' + if platform.uname().system == "Linux": + os.chmod("./psvimg-extract", stat.S_IRWXU) + command = f'./psvimg-extract -K {key} game/game.psvimg game_dec' print(command) if os.system(command) != 0: print("Decryption failed with the above information.") @@ -22,7 +25,9 @@ def decrypt_game(key, src, pboot, game_id): def encrypt_game(key, src, dst): print("\nEncrypting:\n") os.chdir(src) - command = f'psvimg-create -n game -K {key} game_dec "{dst}/game"' + if platform.uname().system == "Linux": + os.chmod("./psvimg-create", stat.S_IRWXU) + command = f'./psvimg-create -n game -K {key} game_dec "{dst}/game"' print(command) if os.system(command) != 0: print("Game Creation failed with the above information.") @@ -38,10 +43,18 @@ def make_dir(d): def read_hkcu(key: str, val: str): + import winreg with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key, 0, winreg.KEY_READ) as key: return winreg.QueryValueEx(key, val)[0] +def read_conf(val: str): + with open(os.path.expanduser('~/.config/codestation/qcma.conf')) as config: + for line in config.readlines(): + if line.startswith(val): + return line.split("=")[1].replace("\n", "") + + def download(url, dst): request.urlretrieve(url, f'{dst}/{url.split("/")[-1]}') diff --git a/classes/__pycache__/Game.cpython-37.pyc b/classes/__pycache__/Game.cpython-37.pyc index f70391f07aef94b82f2c24c89e70ae6e3d1a790e..82754698b4df78a12be532996ff1d23da50ffd2e 100644 GIT binary patch delta 67 zcmeyu`Gu3uiIRCBh92`x@7Dvn7?%+1J+NzW{aNz2SDDay>t VEUAo1&PgmTPA!hv9K^VY832lv6~_Po diff --git a/classes/__pycache__/User.cpython-37.pyc b/classes/__pycache__/User.cpython-37.pyc index ce41f0c620f97f543437c77c22d194d808f56c6c..e1f0e2f04de8827978e571c995f47c0c4ae37d65 100644 GIT binary patch delta 66 zcmX>lbV`WViIb-iqnp$Q#b6rk|0Yo2s9bn46JnXknzEo>`*rmYEk)l$n=V UQmLPulUQ7wTCBghi}3(E0HIM8+yDRo delta 66 zcmX>lbV`WViI+=@B0kvE)C&Dkm@v^ce>I3_7EHzPMDJ+mYxEiMH&TzPVNTMDTjbtMTMivNn89P7}!4YCflx--cXi|#gL6XI2y2TxG zUh3(UxQk^j)HTp0H=6)?%pb^)nM)2i=?CPZOY&7OwU!ATg3My8d%CN8s;j>Gs&CKD z1q{!>Z~gO+pUyD$FM4_R*y#KY|LPwQf(f3oaMJRS%k01<8I~&dlS2SL+uqiy@qn#5oB0xJY7vzGN{oWEyG55*|7x6a# zJr@gN5pUlEjW(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