FaithLife-Community / LogosLinuxInstaller

A Python application that helps install and maintain FaithLife's Logos Bible (Verbum) Software on Linux through Wine.
MIT License
35 stars 10 forks source link

Add Ability to Detect When Logos is Running #164

Closed thw26 closed 1 month ago

thw26 commented 3 months ago

This PR aims to resolve #137. It does three things. First, it lists out the kwargs for run_command. Second, I do the same for popen_command. Then there's the big kahuna. As per the commit notes:

All of these changes together in that commit work to create a State Manager for Logos. The new config vars in place are perhaps overkill, but they are effective and give us room to use them in the future if ever desired.

Logos.py adds a new class: LogosManager. It also adds in a State class that is just an enum. The manager has a few commands to go with it:

The start and stop functions can be called independently. The stop commands are effectively kill commands, and should only be run when shutting down for forcing a shut down.

The class is designed to be updated through the monitor command. The monitor command polls the main Logos and Indexing functions and through their processes determines if the program is running, starting, or stopped. This is maintained through two class variables tracking the state of Logos and the Indexing.

Logos has three processes which are spawned: there is the launching program, which I've called splash—this is what the .exe launches. There are then two other processes: the login command and the actual program, the .exe of which is called LogosCEF. Each of these have to be tracked independently since the latter two are children of the splash, and not of Wine, which means we can't track them through run_command or popen_command.

The way I use this in the TUI is simple.

In the tui_app's main loop, display(), we begin by calling self.logos.monitor(), where self.logos is an app instance of LogosManager, in order to not have empty variables.

Then, during the loop, we run a utils.stopwatch() every 2.5 seconds to determine if the monitor command should be run again. If 2.5 seconds have passed, then we run the monitor() again. After the monitor is triggered, we also run an update to the main menu options to determine if Logos and Indexing should display Run or Stop for the particular program.


I also found there were numerous other issues while attempting to fix #142 and #153. Per the commit notes, this PR now also does:

thw26 commented 3 months ago

My recent push resolves the ability to detect whether Logos is running or not. To do:

thw26 commented 2 months ago

After adding the state manager, there has been a regression. I need to figure out why stopping doesn't work again.

thw26 commented 2 months ago

I added a commit to fix #153. I also changed utils.stopwatch to accept floats and reduced the TUI app's monitor refresh rate from 3 to 2.5seconds. CPU usage still seems reasonable.