* monitor.on_foot is now monitor.state['on_foot'] as plugins need to
access it.
* EDDB:journal_entry() now stores that in this.on_foot to check later.
* this.on_foot checked in cmdr_data() to actually set station name from
that data if needs be. This avoids setting it to STATION_UNDOCKED if
data['commander']['docked'] is False, when we're on_foot.
Well, it doesn't now raise ServerLagging for a last Journal with a
LoadGame on-foot and in-station.
It does then cause "You're not docked at a station!" to show up.
This way we can tell the difference between:
1. This process obtained the lock.
2. Another process has the lock.
3. We couldn't get the lock due to not being able to open the lock file
read-write.
Case 3 is currently also returned if the configured journal directory
doesn't exist. This will be the case on any MacOS system that never had
the game running. Likely given the OS hasn't been supported for the
game in years now.
# Conflicts:
# EDMarketConnector.py
* Implement JournalLock.release_lock().
* Renamed other methods to remove journaldir_ prefix.
* Slightly tweak the code flow for obtaining the lock.
* Implement JournalLock.update_lock(), called from AppWindow.postprefs().
# Conflicts:
# EDMarketConnector.py
* Use a lock file in the journals_dir location to prevent more than one
instance running against the same journals. We no longer check just
for a Windows handle. So this is more correct on win32 *and* is now a
thing on all other platforms.
* Adds `--suppress-dupe-process-popup` CL arg to suppress "we're a
dupe!" popup to aid those using batch files to launch EDMC alongside
the game.
* Two minor fixups of typos in PLUGINS.md.
* Misc noqa comments and other flake8 fixups. We're now only missing
type annotations in EDMarketConnector.py.
# Conflicts:
# EDMarketConnector.py
1. So now they're only defined in one place.
2. config.py does an import of them, and `from config import ...` then
chains through, so no need to update other users.
3. No need to ' # noqa E402' the killswitch/config imports now.
1. Moved the rest of the __main__ code so it's all in one block again.
2. Duplicate defined applongname, and protocolhandler.redirect as
protocolhandler_redirect so that the process checking works.
1. We were now importing from config before the console redirect code
runs.
2. That means that config.py's `logger = logging.getLogger(appname)`
caused the logger to be set up whilst stdout/err were still pointing
at the console.
3. So the redirect then had no effect on logging output.
This commit moves the import from config (and also killswitch, because
it also imports logging) to after the *moved* console redirect code.
NB: This needs the "detected a process already running" instance
checking.
NB: There's still a `True or ` for testing purposes EDMarketConnector.py:25
# Conflicts:
# EDMarketConnector.py
* This is now done even before the stdout/err redirect.
* The function is now called no_other_instance_running() to make the
conditional use of it read more naturally.
* For now this *append* logs to the plain log file. **BUT** any
subsequent write by the already-running process will be over the top
of this, so a future commit will use a popup instead.
# Conflicts:
# EDMarketConnector.py
1) Don't log in this check, we're a different process.
2) But we've stomped the plain log file already!
3) Python 3.8.6 seems to not like sys.exit(0) from that ctypes code, so
`return False` instead and check the return from EnumWindows().
And added `# type: ignore` comments.
This is a mess. On the tkinter side it *is* an int, default 0. But
enough python stuff has assumed it's a bool for typeshed to define that
tearoff should be. It doesn't match, mypy complains.