feat: support linux & basic wine functions

This commit is contained in:
2024-05-30 19:55:55 +02:00
parent 06cd7d4cac
commit cb03300eb2
4 changed files with 39 additions and 17 deletions

View File

@@ -4,6 +4,7 @@ import yaml
import software import software
import ftplib import ftplib
import tqdm import tqdm
import ssl
class SESSION_REUSE_FTP_TLS(ftplib.FTP_TLS): class SESSION_REUSE_FTP_TLS(ftplib.FTP_TLS):
"""Explicit FTPS, with shared TLS session""" """Explicit FTPS, with shared TLS session"""
@@ -138,6 +139,7 @@ class FTP(DataBackend):
ftp = ftplib.FTP() ftp = ftplib.FTP()
else: else:
ftp = SESSION_REUSE_FTP_TLS() ftp = SESSION_REUSE_FTP_TLS()
ftp.ssl_version = ssl.PROTOCOL_TLSv1_2
ftp.connect(server, port=port or 0) ftp.connect(server, port=port or 0)

View File

@@ -1,6 +1,12 @@
import subprocess import subprocess
import sys
import os import os
# windows imports #
if os.name == "nt":
import win32com.client import win32com.client
else:
os.environ.update({"WINEARCH": "win64"})
def _template_registry_file(template_file, game_path=None): def _template_registry_file(template_file, game_path=None):
'''Template the registry file before installation''' '''Template the registry file before installation'''
@@ -16,9 +22,15 @@ def install_registry_file(registry_file, game_path=None):
# test path: # test path:
# ./example_software_root/FreeDink/registry_files/game_path_example_1.reg # ./example_software_root/FreeDink/registry_files/game_path_example_1.reg
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 # # windows sucky sucky #
if not os.path.isabs(registry_file): if not os.path.isabs(registry_file):
registry_file = os.path.join(os.getcwd(), registry_file) registry_file = os.path.join(os.getcwd(), registry_file)
p = subprocess.Popen(["python", "regedit.py", registry_file], p = subprocess.Popen(["python", "regedit.py", registry_file],
subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True) subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
@@ -29,13 +41,21 @@ def install_extra_files(extra_files_list, path):
pass pass
def resolve_lnk(lnk_file_path): def resolve_lnk(lnk_file_path):
if os.name == "nt":
shell = win32com.client.Dispatch("WScript.Shell") shell = win32com.client.Dispatch("WScript.Shell")
shortcut = shell.CreateShortcut(lnk_file_path) shortcut = shell.CreateShortcut(lnk_file_path)
return shortcut.TargetPath return shortcut.TargetPath
else:
return lnk_file_path # not required on linux
def run_exe(path, synchronous=False): def run_exe(path, synchronous=False):
'''Launches a given software''' '''Launches a given software'''
if os.name != "nt":
subprocess.Popen(["wine64", path], cwd=os.path.dirname(path))
return
if synchronous: if synchronous:
raise NotImplementedError("SYNC not yet implemented") raise NotImplementedError("SYNC not yet implemented")

View File

@@ -4,4 +4,4 @@ customtkinter
tqdm tqdm
Jinja2 Jinja2
pyyaml pyyaml
pywin32 pywin32==<version>; platform_system=="Windows"