* 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".
* In `develop` config import will set up logging, so let's head that off
at the pass and put the redirect right at the top.
* Also moved the EDMCLogging import to right after the config import's
new position, to emulate `develop` behaviour.
* We *append* on the initial open of the redirect log file. Then once
we're sure we're the only process we truncate this.
The edmc://auth catch/forward code relies on the old "is there another
window with this handle already?" check, so need to reinstate that code
*after* the lock check in order to forward the message.
* The end of the win32/else conditional was identical, so only do that
write to the successfully locked file in one place.
* No need to go out of `__main__` only to go straight back in.
* It *should* only be a PermissionError, although the docs actually say
the 'higher' OSError. This way we will always catch whatever it is.
* The print uses {e!r} so as to make it explicit what the type of the
exception is.
* The variable is journal_dir_lockfile not lockfile.
* Typehint on journal_dir (likely not needed in `develop` as config.py
is cleaned up there).
* Tweak the per-platform prints
1. We need the args available at the top.
2. In `develop` we'd renamed `enforce_single_instance()` to
`no_other_instance_running()` so that it's obvious it's a function
returning a boolean, rather than the function that does the
enforcement.
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.
Although the issue we've identified with GitHub builds isn't to do with
a python module version it's best to nail precise versions so we can be
sure it will build with the same as we've tested locally.
I specifically made set_shutdown() *not* take an argument and only ever
set this true so no-one else can monkey with it, so might as well mangle
it too.