* 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.
This was wrong since 291fbf2908e0f7419769a7727ee0a79cf58a9342 due to the
check saying "only active if in CQC", when it needed to be "only active
NOT in CQC, along with these other conditions".
* Session.profile() was unused (used to be called from stats.py, but
that uses cached data now).
* Session.query() was unused, other than by itself. Normal calls will
currently be via companion.Session.station(). Future CAPI queries
like `/fleetcarrier` might add their own companion.Session function.
* And in doing so get --capi-pretend-down working again.
* Small tweak to EDMarketConnector to not throw extra exception if there
was a CAPI query exception.
* If we don't invalidate then the companion.Auth code will do nothing
due to "already auth'd".
* We need to give the auth flow time to complete, so need to return.
* As that auth flow can take indeterminate time, not setting a timed
retry of the CAPI query here. We should consider setting a flag and
reacting in the Auth code though.
I keep observing it take 3-4s to update the UI after a manual CAPI
request. This showed up as mostly *in*
AppWindow.capi_handle_response(), but the moment I ran it under PyCharm
profile that went down to 400ms.
* The 'EDMC' prefix on all these classes is to make it clear they're for
internal passing around of requests/responses, rather than holding the
literal raw CAPI request and response.
* The request and response queues are now commented, including the
detail that the response queue is created by the caller and then set
'here' by Session.set_capi_response_queue().
EDMC.py will also need to make CAPI queries using the new threaded
method, but it has no tkinter, thus we need to pass in the event name
when we expect one to be generated, and only generate it if this is not
None.