Skip to content

Commit 171bd35

Browse files
committed
feat: use native runners when available for windows builds
1 parent c0b9960 commit 171bd35

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

gogdl/dl/progressbar.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ def loop(self):
3535
timestamp = time()
3636
while not self.completed and (time() - timestamp) < 1:
3737
try:
38-
dl, dec = self.speed_queue.get_nowait()
38+
dl, dec = self.speed_queue.get(timeout=1)
3939
self.downloaded_since_last_update += dl
4040
self.decompressed_since_last_update += dec
4141
except queue.Empty:
4242
pass
4343
try:
44-
wr, r = self.write_queue.get_nowait()
44+
wr, r = self.write_queue.get(timeout=1)
4545
self.written_since_last_update += wr
4646
self.read_since_last_update += r
4747
except queue.Empty:
4848
pass
49-
sleep(0.2)
5049

5150
self.print_progressbar()
5251
def print_progressbar(self):

gogdl/launch.py

+43-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,30 @@
77
from ctypes import *
88
from gogdl.process import Process
99
import signal
10+
import shutil
1011
import shlex
1112

1213
class NoMoreChildren(Exception):
1314
pass
1415

16+
def get_flatpak_command(id: str) -> list[str]:
17+
if sys.platform != "linux":
18+
return []
19+
new_process_command = []
20+
process_command = ["flatpak", "info", id]
21+
if os.path.exists("/.flatpak-info"):
22+
spawn_test = subprocess.run(["flatpak-spawn", "--host" "ls"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
23+
if spawn_test.returncode == 0:
24+
new_process_command = ["flatpak-spawn", "--host"]
25+
process_command = new_process_command + process_command
26+
27+
output = subprocess.run(process_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
28+
29+
if output.returncode == 0:
30+
return new_process_command + ["flatpak", "run", id]
31+
return []
32+
33+
1534
# Supports launching linux builds
1635
def launch(arguments, unknown_args):
1736
# print(arguments)
@@ -42,6 +61,7 @@ def launch(arguments, unknown_args):
4261
if launch_arguments is None:
4362
launch_arguments = []
4463
if type(launch_arguments) == str:
64+
launch_arguments = launch_arguments.replace('\\', '/')
4565
launch_arguments = shlex.split(launch_arguments)
4666
if compatibility_flags is None:
4767
compatibility_flags = []
@@ -57,13 +77,35 @@ def launch(arguments, unknown_args):
5777
if not os.path.exists(executable):
5878
executable = get_case_insensitive_name(executable)
5979

80+
if sys.platform != "win32" and arguments.platform == 'windows' and not arguments.override_exe:
81+
if "scummvm.exe" in executable.lower():
82+
flatpak_scummvm = get_flatpak_command("org.scummvm.ScummVM")
83+
native_scummvm = shutil.which("scummvm")
84+
if native_scummvm:
85+
native_scummvm = [native_scummvm]
86+
87+
native_runner = flatpak_scummvm or native_scummvm
88+
if native_runner:
89+
wrapper = native_runner
90+
executable = None
91+
elif "dosbox.exe" in executable.lower():
92+
flatpak_dosbox = get_flatpak_command("io.github.dosbox-staging")
93+
native_dosbox= shutil.which("dosbox")
94+
if native_dosbox:
95+
native_dosbox = [native_dosbox]
96+
97+
native_runner = flatpak_dosbox or native_dosbox
98+
if native_runner:
99+
wrapper = native_runner
100+
executable = None
101+
60102
if len(wrapper) > 0 and wrapper[0] is not None:
61103
command.extend(wrapper)
62104

63105
if arguments.override_exe:
64106
command.append(arguments.override_exe)
65107
working_dir = os.path.split(arguments.override_exe)[0]
66-
else:
108+
elif executable:
67109
command.append(executable)
68110
command.extend(launch_arguments)
69111
else:

0 commit comments

Comments
 (0)