* 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().
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".
* 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.
1. The updater is in a thread/DLL and we don't want that firing part way
through shutdown, so it gets asked to stop first.
2. Then plugins, so they're out of the way and we won't have already
stopped something they might rely on.
3. Hotkey after that to head off the user triggering something via them.
4. Now stop the programmatic input from Journal files (including
Status.json).
5. Frontier auth handling.
6. And then anything else.
monitor.thread should only be none when there's a <<JournalEvent>> to
process if we're in shutdown, in which case we do *not* want to be
processing journal events.
This is some best effort support for using logging in properties.
This works by using the (as suggested by reporter) inspect
`getattr_static` method, and failing that (as it can possibly fail),
wrapping a `getattr` in a try/catch for a RecursionError--don't want to
catch other things, probably best if that explodes on its own.
From there as the `property` object will not have location information,
we rebuild as best we can to an approximation of what the path would be.
With a healthy dash of defensive programming "Just in case".
I don't think that this will have any adverse effects to other logging
methods, as all the new code should only be touched if we hit a property
object.
Closes#808
Python name mangling is more about name collisions than actually making
things private.
This commit adds a check to resolve mangled names to their runtime
names, and adds a just-in-case default to fetching the attribute.
Fixes#764
* We're using try/except so can just attempt the setting of a UTF-8
encoding. In cases where it doesn't work we'll have some obvious log
output to help diagnose any issues it causes later.
* Cleaned up the comments to be more 'why' than 'what'.
Any running from source, or on a non-win32 platform will attempt to
force UTF-8 encoding.
For frozen win32 we'll rely on the windows manifest setting. On too-old
versions of Windows we'll have to ensure all code works with non-UTF-8
encodings.