Skip to content

Commit

Permalink
Fix #115.
Browse files Browse the repository at this point in the history
  • Loading branch information
thw26 committed Jul 8, 2024
1 parent 3e2d85b commit 9866753
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import utils
import wine

processes = {}


def get_parser():
desc = "Installs FaithLife Bible Software with Wine on Linux."
Expand Down Expand Up @@ -371,5 +373,16 @@ def main():
run_control_panel()


def close():
logging.debug("Closing Logos on Linux.")
if len(processes) > 0:
wine.end_wine_processes()
else:
logging.debug("No processes found.")
logging.debug("Closing Logos on Linux finished.")


if __name__ == '__main__':
main()

close()
16 changes: 16 additions & 0 deletions wine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import msg
import utils

from main import processes


def get_pids_using_file(file_path, mode=None):
# Make list (set) of pids using 'directory'.
Expand Down Expand Up @@ -222,6 +224,8 @@ def run_wine_proc(winecmd, exe=None, exe_args=list()):
stderr=subprocess.STDOUT,
env=env
)
if exe is not None and isinstance(process, subprocess.Popen):
processes[exe] = process
with process.stdout:
for line in iter(process.stdout.readline, b''):
if winecmd.endswith('winetricks'):
Expand Down Expand Up @@ -427,3 +431,15 @@ def run_indexing():
run_wine_proc(config.WINESERVER_EXE, exe_args=["-k"])
run_wine_proc(config.WINE_EXE, exe=logos_indexer_exe)
run_wine_proc(config.WINESERVER_EXE, exe_args=["-w"])


def end_wine_processes():
for process_name, process in processes.items():
if isinstance(process, subprocess.Popen):
logging.debug(f"Found {process_name} in Processes. Attempting to close {process}.")
try:
process.terminate()
process.wait(timeout=10)
except subprocess.TimeoutExpired:
process.kill()
process.wait()

0 comments on commit 9866753

Please sign in to comment.