ConnectionErrors are expected and not something we can fix. The
exception handler that was catching these previously is a catchall
intended to stop EDMC as a whole from crashing from something
unexpected.
Closes#1082
The old "Error: Frontier server is down" can easily be confused as "game
servers are down". The new version calls out the CAPI specifically.
Closes#585
* Expand on the docstring to point out extra queries might be made.
* Add checks for lastStarport and then name within that being properly
present and set.
This is caused, at least on Odyssey Alpha Phase 3, 4.0.0.20, by:
1. Jump to a new system.
2. Don't dock yet.
3. Cause CAPI pull with 'Update' button.
4. The PTS CAPI server is returning:
"lastStarport": {
"faction": "",
"id": 3221604096,
"minorfaction": "",
"name": "",
"services": []
},
So actually we need to decide it's not sane at all.
I've gone with 'None' for when there's no data, rather than {}. That
makes for simpler checks on if there is data (a dict.get('foo') only
checks for that, not the dict structure otherwise).
If no 'suit' in the data we assume no Odyssey, but otherwise plough on
with dict.get() statements as they'll default to None if it's not
present.
*Users* of this monitor.state[] extra data get to choose what to do if
some data is present but not other.
* A lot of this is commented out. It might be useful in the future, but
is just too noisy for now.
* Changed the protocol webserver to info, as it is.
* Left the EDSM 'not 1XX, 2XX or 5XX' in as it's a warning, so 'pass's
on the conditional bodies that would be empty now trace's are
commented.
Also refactors data.py to edmc_data.py as I'm having weird issues with
PyCharm debugger not starting, and this seems to be to do with module
name clashes.
* monitor.on_foot is now monitor.state['on_foot'] as plugins need to
access it.
* EDDB:journal_entry() now stores that in this.on_foot to check later.
* this.on_foot checked in cmdr_data() to actually set station name from
that data if needs be. This avoids setting it to STATION_UNDOCKED if
data['commander']['docked'] is False, when we're on_foot.
NB: No shipyard in tests because data['ships']['shipyard_list'] is an
empty list. This might be the bug not having been fixed, or the station
might genuinely have no ships for sale. We have no way to check in
Odyssey Alpha Phase 1.
Nothing other than /shipyard actually returns the modules and ships
data, so checking for it anywhere other than that automatically is just
asking for extra log noise and nothing else.
* The companion Session.query is called for *all* CAPI endpoints and
only the /profile one will return lastStartport data, which is where
ships/modules are if present, so only do these checks if we see
lastStarport.
Currently it is simply a dict subclass that does some of the cleanup
required to make everything happy. In future it will be changed to be a
NamedTuple or similar that can be typed
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.