diff --git a/client.py b/client.py index 14d2223..9e77699 100644 --- a/client.py +++ b/client.py @@ -317,4 +317,4 @@ if __name__ == "__main__": # fill and run app # load_main() # TODO add button to reopen config # TODO add button to purge cache/purge cache window # TODO show game size on remote - app.mainloop() \ No newline at end of file + app.mainloop() diff --git a/data_backend.py b/data_backend.py index 739aeca..72ba3b2 100644 --- a/data_backend.py +++ b/data_backend.py @@ -4,6 +4,7 @@ import yaml import software import ftplib import tqdm +import ssl class SESSION_REUSE_FTP_TLS(ftplib.FTP_TLS): """Explicit FTPS, with shared TLS session""" @@ -138,6 +139,7 @@ class FTP(DataBackend): ftp = ftplib.FTP() else: ftp = SESSION_REUSE_FTP_TLS() + ftp.ssl_version = ssl.PROTOCOL_TLSv1_2 ftp.connect(server, port=port or 0) @@ -262,4 +264,4 @@ class FTP(DataBackend): local_meta_file_list.append(f) return list(filter(lambda x: not x.invalid, [ software.Software(meta_file, self, self.progress_bar_wrapper) - for meta_file in local_meta_file_list ])) \ No newline at end of file + for meta_file in local_meta_file_list ])) diff --git a/localaction.py b/localaction.py index a68607b..c1b9535 100644 --- a/localaction.py +++ b/localaction.py @@ -1,6 +1,12 @@ import subprocess +import sys import os -import win32com.client + +# windows imports # +if os.name == "nt": + import win32com.client +else: + os.environ.update({"WINEARCH": "win64"}) def _template_registry_file(template_file, game_path=None): '''Template the registry file before installation''' @@ -13,29 +19,43 @@ def unpack_software(software_cache_path, target_path): def install_registry_file(registry_file, game_path=None): '''Install a given registy file''' - # test path: + # test path: # ./example_software_root/FreeDink/registry_files/game_path_example_1.reg - # windows sucky sucky # - if not os.path.isabs(registry_file): - registry_file = os.path.join(os.getcwd(), registry_file) - p = subprocess.Popen(["python", "regedit.py", registry_file], - subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) - + if sys.platform.startswith("linux"): + p = subprocess.Popen(["wine64", "start", "regedit", registry_file], + subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + print("Running regedit for wine..") + else: + # windows sucky sucky # + if not os.path.isabs(registry_file): + registry_file = os.path.join(os.getcwd(), registry_file) + + p = subprocess.Popen(["python", "regedit.py", registry_file], + subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) + print(p.communicate()) - + def install_extra_files(extra_files_list, path): '''Copy/Install extra gamedata to a give location''' pass def resolve_lnk(lnk_file_path): - shell = win32com.client.Dispatch("WScript.Shell") - shortcut = shell.CreateShortcut(lnk_file_path) - return shortcut.TargetPath + + if os.name == "nt": + shell = win32com.client.Dispatch("WScript.Shell") + shortcut = shell.CreateShortcut(lnk_file_path) + return shortcut.TargetPath + else: + return lnk_file_path # not required on linux def run_exe(path, synchronous=False): '''Launches a given software''' + if os.name != "nt": + subprocess.Popen(["wine64", path], cwd=os.path.dirname(path)) + return + if synchronous: raise NotImplementedError("SYNC not yet implemented") @@ -48,7 +68,7 @@ def run_exe(path, synchronous=False): subprocess.Popen(path, cwd=os.path.dirname(path)) except OSError as e: if "WinError 740" in str(e): - p = subprocess.Popen(["python", "adminrun.py", path], + p = subprocess.Popen(["python", "adminrun.py", path], subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) print(p.communicate()) else: @@ -64,4 +84,4 @@ def uninstall_registry_file(registry_file): def uninstall_extra_files(extra_file_list, path): '''Uninstall all extra game data''' - pass \ No newline at end of file + pass diff --git a/requirements.txt b/requirements.txt index 60c2375..8a62d74 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ customtkinter tqdm Jinja2 pyyaml -pywin32 +pywin32==; platform_system=="Windows"