* When PyCharm made a mess I accidentally undid two renames in
EDMarketConnector.py...
* ... but one of those actually *does* need to only close the session. So
made a new Session.close() that performs only the closing, with
Session.reinit_session() now utilising that.
* Added `capi.request.<endpoint>` killswitches at appropriate call points.
* Added `eddn.capi_export.<type>` killswitches. This allows for killing
just the EDDN export of such CAPI-derived data, without stopping the actual
queries, as other plugins/functionality might still have harmless use of
the data.
* PLUGINS.md: Actually describe the contents of `data` passed to plugins, and
point out it might not always contain market or shipyard data. This is
not only because of the new killswitches, but could already have happened
if the station/port docked at didn't have the services.
* Some misc typing cleanups.
* New CL arge `--killswitches-file`. This needs to reference a file either
with an absolute path, or relative to the CWD of the process.
* Internally if the argument is provided it is prefixed with `"file:"` in
order to actually be loaded. This is because `requests` doesn't have an
adapter for `file:` URLs.
* Also fixes a visual bug with reporting of active killswitches. The entire
SingleKill object was used instead of just its `reason` property. mypy
type checks caught this.
It can be `tk.NORMAL` or `tk.DISABLED`. Why `True` was ever used I don't
know, possibly relying on undefined behaviour.
However, those 'types' end up as `Literal['normal']` and `Literal['disabled']`
and the only way to declare a Union of those is to be explicit with the
actual strings. tk.(NORMAL|DISABLED) are not a types.
* Renames `plug.notify_newdata()` to the more precise `notify_capidata()`.
* If CAPI data was from SERVER_LEGACY, then use plugin `cmdr_data_legacy()`
instead of `cmdr_data()`.
* Move it later, after CLI args processing. This would allow for a magic
'override' this, providing a key or similar.
* Correct text 'XAthan' to 'Athan' in 'win32' check.
* If `git_branch != 'develop'` check if `-alpha0` is in the app version.
Such version strings are never in any pre-release or release.
This has been relying on knowledge of the magic numbers for far too long.
As part of this, remove all the obfuscating "oh, default is 0, and we want
that or any other theme, so treat this like a boolean" nonsense.
Also, stop assuming that "> 1" is a synonym for "transparent theme". Just
Do The Equality Check.
* This is *temporary* pending properly implementing utilising the Legacy
CAPI host.
* Check in the EDMarketConnector.EDApp.capi_request_data() function *and*
also in some companion.session functions. But not absolutely all possible
entry points because we'll be undoing it when we implement Legacy support.
This *is* sufficient for the current core code entry points. If any plugin
is invoking its own CAPI requests, well it shouldn't be.
This flag controls whether commodity, outfitting or shipyard schema messages
are sent. Thus 'MKT' ('market') is misleading. Rename it so the intent when
used is clear.
1. It's not actually hiding the task bar icon currently.
2. As this touched prefs.py I've done a flake8 and mypy cleanup pass
too. But some of that will want reviewing later as I noqa'd some
things.
This allows you to force use of an expired token so as to test the code
paths for that without waiting up to 4 hours for the current one to
expire.
NB: The Access Token is *only* stored in the headers of the `requests`
object.
The old code did this, and without it we enter a loop of:
1. CAPI says unauthorized
2. We call login()
3. But companion.session.state == STATE_OK, so do nothing
4. Re-scheduled CAPI request goes back to 1.
1. Logged out in space
2. Logged back in
3. Run EDMC
4. Hit Update button, get "Docked but unknown station: EDO Settlement?"
In investigating this I realised that the entire else needed to be "if
docked according to CAPI".
Then it became clear that there was a redundant conditional, as the
enclosing one is already testing:
`capi_response.capi_data['lastStarport']['name'] != monitor.station:`
Making the:
`if last_station != monitor.station`
conditional un-necessary.
This will only work on startup for now, with it present/active the EDDN
plugin will add a UI frame to show what it's tracking.
Intended for developer use only.
In general, doing things like this on import is bad, but this was
changed specifically to remove a bug that causes
--force-localserver-auth to do nothing.
That is caused because while we were careful not to import protocol
until after we were done doing arg things, we did not check to make sure
something else didn't. Companion imports protocol, which thus always
instantiates WindowsProtocolHandler before we can modify some config
state to indicate that we want LinuxProtocolHandler.
This also entailed slightly reworking the way the EDDN code uses this
URL. It was very generalised, so as to allow for the debug "just send
and log locally" code, but as the only URL is the 'upload' one much of
that seemed un-necessary.
So that code has been simplified.