* If it's None then set journal_dir_path to None as well. Setting '' or
nothing results in '.' (CWD), which could cause other issues.
* As we do this in three places, it's in a helper function.
* New JournalLockResult.JOURNALDIR_IS_NONE to signal this.
* Fix checking of return from obtain_lock() to specifically reference
JournalLockResult.ALREADY_LOCKED.
In the scenario of the default Journals location not even existing the
user needs might update it to a network mount. When they do so we
attempt, and fail, to unlock the old location, despite it not being
locked.
So now we have this boolean so we know if we should even attempt
unlocking.
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.
I'd `git show develop:journal_lock.py > journal_lock.py` a copy in
before, but forgot to commit it, and then removed it when checking out
another branch complained. D'oh!
I was testing the new Steam or Epic CAPI auth. My EGS account hasn't
yet been used, so has no commander attached. EDMC thinks the auth has
succeeded in this case, but hitting 'Update' causes it to error because
the returned data is empty.
So, add some checks for lack of 'commander' key and a specific message
"CAPI: No commander data returned" for status line.
Without this there's a KeyError exception thrown, causing the status
line to just get 'commander' in it, which isn't helpful.
The actual duplicate process checks *used* to be done in this function,
but no longer are. Instead it's now specifically performing the "is
this an edmc:// auth callback?" check, including the foreground of the
extant process if needs be.
* 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().
Tested with a build/install and run with:
"c:\Program Files (x86)\EDMarketConnector\EDMarketConnector.exe" --force-localserver-for-auth --trace
2021-01-22 12:57:11.020 - TRACE - protocol.ProtocolHandler.__init__:222: Web ser
ver listening on http://localhost:53657/auth
Without this we only truncate to where the file was when we did the
stdout/err redirect.
What I observed was it truncated out the "journal locking" output, but
not anything from a prior run of the program.
* The "truncate the stdout redirect" code was erroneously inside the
else of a try.
* Added some comments about exceptions found on Linux when unable to
open the journals_dir lock file
* Changed 'assuming another process running' logging to not split lines.
* "Couldn't open <journal lock file>" isn't inside no_other_instances()
so made the message more obvious.
* We're not going to refactor those 'complex' sections any time soon, so
clean up flake8 output for now.
* No-one still uses "send SIGTERM to see a stack trace".