Commit Graph
70 Commits
Author SHA1 Message Date
Athanasius abc1507aa0 Also allow sending empty commodities from Market.json 2020-09-28 13:02:10 +01:00
Athanasius dea7b3660a Minor formatting cleanups 2020-09-28 12:48:53 +01:00
Athanasius e908cce242 Change the multi-line conditional to using () not \\n 2020-09-28 12:41:44 +01:00
Athanasius ca4214fff8 EDDN: Catch and log 'we tried to send empty market'.
Very tight check on this to be sure we don't ignore other errors.

	r.status_code == 400  # Not a different code
	$schemaRef == commodities
	The message had empty commodities list
	r.text == expected return from EDDN Gateway
2020-09-28 12:26:09 +01:00
Athanasius 9564d8ab4f EDDN: Allow sending of empty market data for updating FCs. 2020-09-28 12:00:28 +01:00
Athanasius a3b69fd94d Switch internal plugins to EDMCLogging.get_main_logger() 2020-09-22 16:20:05 +01:00
Athanasius f485ffa737 Correctly return and receive bare Tuple, not nested. 2020-09-18 12:59:09 +01:00
Athanasius 22a8da5bf7 Add ships sanity checking, and it's all in a helper function now.
* Moved these modules and ships checks to safe_modules_and_ships().
* Applied some paranoia checks to ships as well.
2020-09-18 11:38:20 +01:00
Athanasius 81f71c88ff Catch where station modules from CAPI is an empty list.
Out of paranoia we're also checking if it's a non-empty list and logging
that as an error if encountered.  It should be a dictionary!
2020-09-18 11:15:15 +01:00
Athanasius 31203270bc Switch to "thing is None" on tests. 2020-09-14 15:43:15 +01:00
Athanasius 735e37e10e Revert is_horizons to modules: MAP_STR_ANY as it works 2020-09-14 13:32:06 +01:00
Athanasius d45070c249 plugins/eddn: Tweak ships/modules in export of shipyard and outfitting from CAPI
There are cases where a station/FC doesn't have outfitting modules or a
ships list.  Let's make the checks happen in both those functions and be
extra paranoid with some logging.

Closes #671
2020-09-14 13:26:20 +01:00
Athanasius 99bac688af eddn: Tweak replay.jsonl try/except flow
* Catch OSError instead of Exception (which is *too* general).
* Put the set of self.replaylog in try/else so it only runs when there
  are no errors.
2020-09-09 14:36:38 +01:00
Athanasius 5e35012611 eddn: flake8 cleanups
* That "EDDN send failed" was too long, so now it's '''-formatted.
* journal_entry() cognitive complexity isn't changing any time soon.
2020-09-09 14:17:39 +01:00
Athanasius 48077f6a30 eddn: Straighten out replay.jsonl opening & minor cleanups.
* The logic for opening replay.jsonl, and detecting if the file was
  already there or not was tortured.  No longer.
* Changed a few logger.debug(..., exc_info=) to logger.exception().
* Changed all logger.warn() (deprecated) to logger.warning().
2020-09-09 14:03:40 +01:00
Athanasius 5d612822da eddn: Tweak the extra EDDN failed message logging format.
It's more readable with \n between each part, and added a prefix.
2020-09-09 13:51:15 +01:00
Athanasius e693af1283 EDDN: Log the message we tried to send if it fails. 2020-09-08 18:51:17 +01:00
A_D de872cdfa6 Added warning log messages 2020-08-07 15:46:46 +02:00
A_D 7adf522de9 Replaced repeated code with helper function 2020-08-07 15:18:33 +02:00
A_D a88cb454da Removed todo related to Horizons 2020-08-07 14:54:43 +02:00
A_D 94418dc4fa Switched to using pathlib 2020-08-07 14:54:04 +02:00
A_D 17f8433a6a clarify comment 2020-08-07 14:45:48 +02:00
A_D 237e5ce52d Replaced subscript and concat with replace() call 2020-08-07 14:43:53 +02:00
A_D b5d3b89a3c Added docstrings and further type annotations 2020-08-07 14:39:12 +02:00
A_D a21280ed3b reordered imports 2020-08-07 13:32:01 +02:00
A_D 5aa6795773 Type annotate all the things! 2020-08-07 13:20:24 +02:00
A_D 94c4a7b7d0 Replaced static lists with tuples 2020-08-07 13:20:24 +02:00
A_D cea8ac49ca Ensured that regexps are raw strings
Ensures that there are no weird excaping issues
2020-08-07 13:20:23 +02:00
A_D e477f89664 removed un-needed object subclass 2020-08-07 13:20:23 +02:00
A_D 3c66ab7246 removed unused imports 2020-08-07 13:20:22 +02:00
A_D 6772c84a5f fixed names where possible 2020-08-07 13:20:22 +02:00
A_D c0026cea61 replaced list comps with generators 2020-08-07 13:20:21 +02:00
A_D c012ebc54e Replaced modulo-formatting with fstrings
Specifically did not replace `somefile.write('%s\n' % some_data)` as
print may change the line endings on some OSes which may not be wanted
2020-08-07 13:20:21 +02:00
A_D 4105662fb5 Cleaned up logic and removed overlong lines
Generally for the logic cleanups it was replacing giant list
comprehensions with slightly smaller filter calls. filter() is just
plain cleaner when all you're doing in a list comp is
[x for x in y if somecondition].
2020-08-07 13:20:21 +02:00
A_D 4d0cf4e335 Added scope change newlines 2020-08-07 13:20:20 +02:00
A_D b186e97747 autoformatted code 2020-08-07 13:20:19 +02: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 2e58d106bd logging.getLogger(appname) instead of import from EDMarketConnector
Using:

from EDMarketConnector import logger

causes issues if EDMarketConnector is already importing 'this' file.

So just get a logger using logger.getLogger(appname) instead.
`from config import appname` if needs be.
2020-07-27 06:57:52 +01:00
Athanasius 6aa409388e plugins/eddn: Converted to proper logging 2020-07-27 06:57:52 +01:00
Athanasius ef3306e3f5 Remove all use of defunct 'anonymous' option
The UI for setting the 'anonymous' option was removed in
f17f5d3f25 ("PKCE OAuth2 access to cAPI").
Since then there's been no way for a user to set, or unset, this option
(and the associated custom uploaderID).  However anyone with the registry keys
still set would have had them take effect.

This commit removes the last bits of code that were making use of it.

Note that the EDDN Relay anonymises all uploaderID values, so no listener
has been seeing the 'raw' values for a long time now.

close #575
2020-07-10 08:36:13 +01:00
Athanasius 89f113e190 Use Preferences Save Serial Number instead of flag
* new class `PrefsVersion` in prefs.py.  A singleton `prefsSaved` (note
   case) is created.
 * When new preferences are added and require defaults on first run the
   code should use:

     `if prefsVersion.shouldSetDefaults(<prior release version>, [<optional old test>]):`

   to check if defaults should be set in preferences.  So if prior release
   was '3.4.6.0' and you've added a new preference with defaults you should
   call this with '3.4.6.0' as the first argument.
   The <optional old test> is really only for historical purposes, as a
   fallback in case no 'PrefsVersion' has yet been set in the user's
   Registry/settings file.
 * Any code that adds such a new preference **MUST** make changes to the
   `versions` dictionary in the PrefsVersion class.
     1. Add the predicted next version to the dictionary, with number one
        higher than 'current'
     2. Set 'current' equal to that new value.
   Obviously if other post-last-release code has already done this then you
   don't need to.

   Failure to update the versions dictionary in this manner will lead to an
   Exception being raised, and the code the preferences are for failing
   (i.e. EDDN means no EDDN tab on Settings).

Closes #407
2020-07-01 15:33:42 +01:00
Athanasius 63c2ff52e9 Fix an Output/EDDN option combination causing defaults to get re-set
Change Output and EDDN options to only get set to defaults if key 'PrefsDidSave' is not present and true.  This gets a value of 0x1 saved any time preferences are applied.

The issue was that if you had sufficient options set such that the saved 'output' value was 0x0 then that would evaluate to false and cause the defaults to get set.

Fixes #407
2020-06-29 14:32:25 +01:00
Athanasius 259bb3bbd6 Merge branch 'release-final-python27' into python3 2020-06-21 16:43:02 +01:00
Jonathan Harris c62d110448 Plugin migration 2020-06-21 16:33:13 +01:00
Athanasius 93a65b02f5 plugins/eddn.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius 143d6e717a plugins/eddn.py: De-future 2020-06-21 16:23:01 +01:00
Athanasius faf5bee834 Fixes plugins/eddn massaging of economies and prohibited data 2020-06-21 16:23:00 +01:00
Athanasius ce460712e2 Ensure we definitely can add mandatory fields to EDDN messages
This came to light due to python3 not liking try['StarPos'] =
list(this.coordinates) if this.coordinates was None.  As the comment
says these three fields are mandatory, ensure we can actually set them
appropriately, and display an error if not.
2020-06-21 16:23:00 +01:00
Athanasius fd4acae9a5 plugins/eddn.py: encode() un-necessary 2020-06-21 16:23:00 +01:00