1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

187 Commits

Author SHA1 Message Date
Athanasius
431d83b5ca companion: Tweak 'server returned an error' message & translate 2021-05-21 14:32:26 +01:00
Athanasius
89c486401e Translations: companion.py "Frontier CAPI query failure" 2021-05-21 14:25:51 +01:00
Athanasius
9cfa60ae26 CAPI: Make user-visible error text more obvious
Mostly call out this is 'Frontier CAPI' related.
2021-05-21 14:23:35 +01:00
Athanasius
1bc1a4f1b9 CAPI: Changed "CAPI down" message to be specific
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
2021-05-17 12:10:08 +01:00
Athanasius
bd1b86d3a3 Suits/Loadouts: Always convert to dict form for simpler downstream code. 2021-04-29 11:30:55 +01:00
A_D
0913cff472
fixed import order 2021-04-16 17:46:22 +02:00
A_D
a3e0823701
Added utility sparse list index function
Frontier sometimes uses dicts as sparse lists, this should work to index
them either way. Doctests included do pass.
2021-04-16 17:36:53 +02:00
Athanasius
e4f7c998cd companion: Improve station() checks and documentation
* 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.
2021-04-15 19:39:40 +01:00
Athanasius
74a3bea619 CAPI: catch lastStarport->services being an empty list (not dict)o
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.
2021-04-15 18:16:41 +01:00
Athanasius
53f8209820 Move AppWindow.dump_capi_data() to be in companion.Session instead
It's writing CAPI data to a file, so it should be in companion.py.

Also:

* Use companion.CAPIData as type, not a Mapping.
2021-04-15 16:56:03 +01:00
Athanasius
2246278286 Odyssey Suits: Store available data from CAPI.
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.
2021-04-13 12:12:51 +01:00
Athanasius
99d90b52b1 translations: Re-order as per l10n.py output & some added
* Generic 'Error'.
* Strings for Access Token customer_id != FID.
* Other strings in companion.py now translating.
* Missing colon on Plugins string.
2021-04-12 14:58:03 +01:00
Athanasius
ffc8d2fcb8 Add comment about assuming FID always starts 'F'. 2021-04-12 12:52:05 +01:00
Athanasius
0575c3ff43 companion: Don't over-write all CredentialsError with generic one 2021-04-12 12:38:23 +01:00
Athanasius
ca08339dfe companion: /decode access token and check customer_id matches FID 2021-04-12 12:37:17 +01:00
Athanasius
5c7aa4dfa9 companion: commented-out example of requests/http debug logging 2021-04-12 12:03:11 +01:00
Athanasius
2686500d65 companion: Split Frontier Auth URL string over lines
This way a change to one part is an easier to read diff.
2021-04-12 11:05:11 +01:00
Athanasius
e34deb5388 companion.py: Fix lints
mypy is still a PITA with `Optional[<type>]` thinking the variable is
`None` at points and refusing to believe it has methods the non-None
type has.
2021-04-12 08:31:48 +01:00
Athanasius
bc6557dd9c Quieten various TRACE log output.
* 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.
2021-04-12 08:31:47 +01:00
Athanasius
ad8c63c64c Move util_ships.py ship_map to data.py ship_name_map
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.
2021-04-12 08:31:47 +01:00
Athanasius
5db62e48a3 Move companion.py category_map into data.py 2021-04-12 08:31:46 +01:00
Athanasius
b70efab345 companion.py: Another s/on_foot/OnFoot/ for monitor.state 2021-04-12 08:30:51 +01:00
Athanasius
f45f817fa2 EDDB plugin now setting Station name correctly on_foot
* 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.
2021-04-12 08:30:51 +01:00
Athanasius
567cfdb9ca Will now send data to EDDN when on-foot in-station.
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.
2021-04-12 08:30:51 +01:00
Athanasius
a09512f3b3 Mostly refactoring companion.ship_file_name() into util_ships.py
* Also prevent "You're not docked at a station!" for on_foot.
2021-04-12 08:30:51 +01:00
Athanasius
2f9789afdd Update all code to use config.appversion() as a function
This *also* caught some instances where appversion_nobuild should
already have been used, so those were both changed and updated to a
function call.
2021-04-01 14:45:52 +01:00
A_D
557e88bc44 removed extra check 2021-04-01 14:45:51 +01:00
A_D
b7c20facdd Fix spurious modules or ships was None
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.
2021-04-01 14:45:51 +01:00
Athanasius
d7d3dc19e4 companion.py: Add Auth destructor to close session.
It's created in the constructor, so destructor is the place for this.
2021-04-01 14:45:50 +01:00
A_D
051245cf90 Renamed various config values to be backwards compatible 2021-04-01 14:45:48 +01:00
A_D
278480b99f replaced ors with defaults in config usage 2021-04-01 14:45:46 +01:00
A_D
f76e5d331e Removed cast calls 2021-04-01 14:45:46 +01:00
Athanasius
25852997c5 Updated all source to use new config methods
# Conflicts:
#	monitor.py
2021-04-01 14:45:46 +01:00
Athanasius
6ec24157f2 CAPIData: Only call self.check_modules_ships() if lastStarport present
* 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.
2021-04-01 14:45:45 +01:00
A_D
fbd924d5aa Added CAPIData class
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
2021-04-01 14:45:44 +01:00
Athanasius
cc2395ca04 Add similar extra logging for localhost handler
* This also adjusts the logging in Session.auth_callback() because it
  can be called from either protocol.  Saying 'edmc://' there is
  misleading.
2021-03-15 12:13:28 +00:00
Athanasius
4f524a0a35 Add extra logging for Frontier Auth, especially via edmc:// 2021-03-15 12:07:39 +00:00
Athanasius
71858357eb CAPI: Log if no commander in profile() data 2021-03-06 18:54:24 +00:00
Athanasius
67a91cf7d1 CAPI: Handle when we get no 'commander' in returned data.
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.
2021-03-06 18:54:18 +00:00
Athanasius
5f3bd9be71 Add Steam and EGS to Frontier Auth audiences. 2021-03-06 18:54:12 +00:00
Athanasius
1aba1a0596 Trace: Change several calls from debug to trace. 2020-09-23 22:07:18 +01:00
Athanasius
85d45aadd7 Place detailed logging for "Location" events.
To try and track down what's happening with #713
2020-09-23 11:45:48 +01:00
Athanasius
22b3362c20 companion.py: Switch to using EDMCLogging.get_main_logger()
So that we use the correct one for GUI versus CLI.
2020-09-22 15:37:56 +01:00
Athanasius
030ae05889 Adjust return type of companion.session.station()
Now we're correctly always returning `data` it can't be None.
2020-09-18 12:58:16 +01:00
Athanasius
be541571d9 companion.py: Return CAPI data if not docked
Else at least one caller to .station() blows up when it can't find the
commander data.

The call has to be to .station() so as to populate the market/shipyard
added dictionaries.
2020-09-18 12:48:21 +01:00
Athanasius
14d1a0ad5e companion.py: Re-format next(...) to be more obvious. 2020-09-15 17:30:23 +01:00
Athanasius
ed52528718 companion.py: Slight tweaks from running mypy
NB: Using `mypy --follow-imports skip` for now to limit how much it
checks each time.
2020-09-15 16:15:13 +01:00
Athanasius
c311957eff companion.py: import requests does belong down there. 2020-09-15 15:49:28 +01:00
Athanasius
55fcfbeb17 companion.py: Further PyCharm-prompted cleanup.
* Correct use of error[0] to just error.
* We don't want methods not referencing self to be static in this case,
  so annotate them.
* Take suggestion of "if v == []:" equivalent to "if not v:".
* Preserve CAPIData typing throughout filter_ship().
2020-09-15 15:33:00 +01:00
Athanasius
4575353923 companion.py: CAPIData type & PyCharm-prompted cleanup.
* CAPI Data really is just a Dict.  Define a custom type so it could
  easily be a class in future with minimal edits.
* Auth.refresh() *can* also return a str (Access Token).
* Catch specific (but still quite loose) exceptions in Auth.refresh().
* Set self.server in Session.__init__.
* Remove some extraneous () on conditionals.
2020-09-15 15:00:22 +01:00