1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-15 00:30:33 +03:00

157 Commits

Author SHA1 Message Date
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
Athanasius
da2a582c46 companion.py: Use custom type for CAPI Data.
This way if we get more stringent about it (could be a class) we don't
need to edit all the references.
2020-09-15 14:35:37 +01:00
Athanasius
c12c739c11 companion.py: Full pass to 100% pass flake8
* docstrings added throughout.
* .format() all now f-strings.
* Type annotations added throughout.
* White space tweaked.
2020-09-15 14:15:07 +01:00
Athanasius
5c3b8b9927 compnanion.py: Add more logging to better trace auth/CAPI flow 2020-09-08 18:52:03 +01:00
Athanasius
19e750eddd Use logger.exception() not log.error(.., exc_info=..) 2020-07-27 10:47:57 +01:00
Athanasius
d7c2372417 Flake8 cleanup round #2 2020-07-27 10:14:16 +01:00
Athanasius
f9a23cc831 Clean up flake8 output for this branch 2020-07-27 09:37:10 +01:00
Athanasius
bae2f25e19 companion.py: Convert to proper logging 2020-07-27 06:57:52 +01:00
Athanasius
71bb14a737 Document allowed imports for PLUGINS
* List added in 'Available imports' section of PLUGINS.md
* Various *.py files now have comments about things being allowed for
 plugin import.
2020-07-12 19:25:47 +01:00
A_D
1481c3d13e
Added todo, removed import
Added a TODO on the incase plugins need it line, and removed the unused
sys import
2020-07-08 21:24:15 +02:00
A_D
09f5dfff23
Replaced assert False with a clearer raise
previously this would assert False, which always raises an
AssertionError, now we raise a saner ValueError
2020-07-08 18:12:15 +02:00
A_D
2890d33d03
Address review comments
Added a missing comma to the category_map literal
Added parens around an index that does math beforehand
Clarified HTTP/JSON error CredentialsError
2020-07-08 18:05:43 +02:00
A_D
dcb9853b68
Removed python2 specific code
This entire branch is py3 only, and even with this code the actual file
isn't py2 compatible syntax wise
2020-07-07 21:52:30 +02:00
A_D
0b6ef97f41
Made dict copy clearer
While `dict(somedict)` does the same thing as `somedict.copy()`, the
.copy is clearer as to intent
2020-07-07 18:46:23 +02:00
A_D
4aa8e2ca0e
Added variable for re-used accesses
The last starport ID and name was repeatedly accessed out of a dict,
making lines longer and harder to parse
2020-07-07 18:42:16 +02:00
A_D
e739923083
Moved User Agent to constant
This is one of those things that really should be a constant anyway
2020-07-07 18:37:05 +02:00
A_D
5c4c9fd3a7
Added error messages to exceptions where possible
Adds messages to exceptions where they may be useful and I could figure
out what they should be
2020-07-07 18:30:29 +02:00
A_D
34b963620a
Removed bare except clauses
Bare except clauses are a fantastic way to find your HTTP requests
eating your ^C. I replaced all bare excepts with Exception if I could
not find a list of exceptions that could be thrown.
2020-07-07 18:21:48 +02:00
A_D
9363b1457d
Simplified if ladder
Removed a large if ladder with a simpler construct that does the same
thing
2020-07-07 16:59:03 +02:00
A_D
31e0758ee4
Replaced x in $list construct with x in $tuple
Tuples are smaller and immutable, therefore using a tuple is cleaner.
2020-07-07 15:52:45 +02:00
A_D
7260dff9a2
Replaced modulo formatting with .format calls
Modulo formatting is py2 (and C printf) style, its arcane and incredibly
hard to read for large formats.

I used keyed .formats where there were more than a few format specifiers
2020-07-07 15:52:44 +02:00
A_D
765dc0bcf3
Replaced oneline ifs with multiline ifs
Oneline ifs are in general a bad idea in whitespace significant
languages, this replaces them with their multi-line equivalents
2020-07-07 15:52:44 +02:00
A_D
56d4d13d4d
Fixed line spacing and comment length
This adds newlines after blocks and in other logical places to assist
with reading the code. Additionally, comments that were too long to
remain inline within a 120 character limit have been moved above the
line they reference.
2020-07-07 15:52:43 +02:00
Athanasius
259bb3bbd6 Merge branch 'release-final-python27' into python3 2020-06-21 16:43:02 +01:00
Jonathan Harris
4daaed7f0c Fix representation of user-defined errors 2020-06-21 16:31:41 +01:00
Athanasius
091a7c22d5 Revert "Lowers companion.py holdoff to 10 seconds"
This reverts commit 93c4f85b3c4c25216ec5f5f62754671b9d8d04e2.
2020-06-21 16:28:29 +01:00
Athanasius
c8f732f7a2 exe: We don't need to explicitly set REQUESTS_CA_BUNDLE any more. 2020-06-21 16:23:02 +01:00
Athanasius
d4a263aab1 companion.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius
2208fdf686 Removes problematic .encode('utf-8')'s in companion.py 2020-06-21 16:23:00 +01:00
Athanasius
e73db981a8 Fixes EDDN sending to be working.
NB: Due to, I assume, EDDN relay de-duplication of messages, it's been
difficult to 100% test this.  No errors thrown, and stock/release EDMC
also doesn't result in a new message arriving at my EDDN consumer.
2020-06-21 16:23:00 +01:00
Athanasius
e7545e174f Use .items() instead of .iteritems() 2020-06-21 16:23:00 +01:00