|
3 | 3 | # - https://tkdocs.com/
|
4 | 4 | # - https://github.com/thw26/LogosLinuxInstaller/blob/master/LogosLinuxInstaller.sh
|
5 | 5 |
|
| 6 | +import copy |
6 | 7 | import logging
|
7 | 8 | from pathlib import Path
|
8 | 9 | from queue import Queue
|
|
25 | 26 | PROMPT_OPTION_NEW_FILE,
|
26 | 27 | )
|
27 | 28 | from ou_dedetai.config import EphemeralConfiguration
|
| 29 | +import ou_dedetai.logos |
28 | 30 |
|
29 | 31 | from . import backup
|
30 | 32 | from . import constants
|
|
34 | 36 | from . import system
|
35 | 37 | from . import utils
|
36 | 38 | from . import wine
|
| 39 | +import ou_dedetai |
37 | 40 |
|
38 | 41 | class GuiApp(App):
|
39 | 42 | """Implements the App interface for all windows"""
|
@@ -441,6 +444,21 @@ def _update_lli_version():
|
441 | 444 | self.update_latest_lli_release_button()
|
442 | 445 | self.gui.update_lli_button.state(['disabled'])
|
443 | 446 | self.start_thread(_update_lli_version)
|
| 447 | + # Spawn a thread to ensure our logos state stays up to date |
| 448 | + def _monitor_faithlife_product_pids(): |
| 449 | + last_state = copy.copy(self.logos.logos_state) |
| 450 | + while True: |
| 451 | + if self.is_installed(): |
| 452 | + self.logos.monitor() |
| 453 | + time.sleep(1) |
| 454 | + else: |
| 455 | + # Will probably be some time before we need to monitor. |
| 456 | + time.sleep(30) |
| 457 | + # If our state changed, we need to update our button. |
| 458 | + if last_state != self.logos.logos_state: |
| 459 | + self.update_app_button() |
| 460 | + last_state = copy.copy(self.logos.logos_state) |
| 461 | + self.start_thread(_monitor_faithlife_product_pids) |
444 | 462 | self.gui.update_lli_label.config(text=text)
|
445 | 463 | self.gui.run_indexing_radio.config(
|
446 | 464 | command=self.on_action_radio_clicked
|
@@ -512,6 +530,9 @@ def run_installer(self, evt=None):
|
512 | 530 | installer_window_top = Toplevel()
|
513 | 531 | InstallerWindow(installer_window_top, self.root, app=self, class_=classname)
|
514 | 532 |
|
| 533 | + def stop_logos(self): |
| 534 | + self.start_thread(self.logos.stop) |
| 535 | + |
515 | 536 | def run_logos(self, evt=None):
|
516 | 537 | self.start_thread(self.logos.start)
|
517 | 538 |
|
@@ -630,8 +651,12 @@ def update_logging_button(self, evt=None):
|
630 | 651 | def update_app_button(self, evt=None):
|
631 | 652 | self.gui.app_button.state(['!disabled'])
|
632 | 653 | if self.is_installed():
|
633 |
| - self.gui.app_buttonvar.set(f"Run {self.conf.faithlife_product}") |
634 |
| - self.gui.app_button.config(command=self.run_logos) |
| 654 | + if self.logos.logos_state == ou_dedetai.logos.State.RUNNING: |
| 655 | + self.gui.app_buttonvar.set(f"Stop {self.conf.faithlife_product}") |
| 656 | + self.gui.app_button.config(command=self.stop_logos) |
| 657 | + else: |
| 658 | + self.gui.app_buttonvar.set(f"Run {self.conf.faithlife_product}") |
| 659 | + self.gui.app_button.config(command=self.run_logos) |
635 | 660 | self.gui.logging_button.state(['!disabled'])
|
636 | 661 | self.gui.app_install_advanced.grid_forget()
|
637 | 662 | self.gui.actions_button.state(['!disabled'])
|
|
0 commit comments