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

278 Commits

Author SHA1 Message Date
A_D
26be93f92e
replaced magic number row with var 2020-09-22 14:48:53 +02:00
A_D
fb080f8080
Removed unused imports 2020-09-22 14:48:53 +02:00
A_D
893cab3c23
cleaned up logic where possible 2020-09-22 14:48:52 +02:00
A_D
f2add920c7
replaced constant contains checks with tuples 2020-09-22 14:48:52 +02:00
A_D
62f3203c3f
Added type checker hint for unbound names
Due to the fact that cmdr and entry are only assigned if item exists, a
situation can arise where any access to the names will raise an
UnboundLocalException, this tells the type checker to ignore that
possibility by using a TYPE_CHECKING guarded assignment to those names.

This does not fix the issue at runtime, it just tells the type checker
that its fine. As this remains a bug, I have left TODOs in to note its
existence.
2020-09-22 14:48:51 +02:00
A_D
7ab697a807
Used default option for .get on dicts 2020-09-22 14:48:00 +02:00
A_D
25adf29779
Fixed possible error if credentials is None 2020-09-22 14:48:00 +02:00
A_D
2c2ade05e0
fixed some naming 2020-09-22 14:46:23 +02:00
A_D
20357b3deb
replaced modulo formatting with fstrings 2020-09-22 14:46:22 +02:00
A_D
81c977d0da
Added type annotations to functions 2020-09-22 14:46:22 +02:00
A_D
14617e72da
cleaned up overlong lines 2020-09-22 14:43:24 +02:00
A_D
199e76701d
Added line breaks around scope changes 2020-09-22 14:43:24 +02:00
A_D
743984eb11
Added fake definition for _
_ is added by magic in the plugin loading system, which means there are
no imports to indicate its existence to static analysis tools.
2020-09-22 14:41:34 +02:00
A_D
d2a1f09fac
sorted imports 2020-09-22 14:41:34 +02:00
A_D
37c53e233e
autoformatted code with autopep8 2020-09-22 14:41:33 +02:00
Athanasius
0f12959d53 plugins/edsm: Also DEBUG log Location and Docked events. 2020-09-22 12:26:54 +01:00
Athanasius
0efe38540f Extend logging to FSDJump as well for ease of testing.
FSDJump happens, relatively, seldom enough to not be too spammy.
2020-09-18 15:33:18 +01:00
Athanasius
3f001a383f plugins/edsm: Add extra logging for CarrierJump events.
We've had reports about EDSM not updating for these, so add logging to
see if it's a bug our end.
2020-09-18 15:15:02 +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
Athanasius
c1d8a61c60 Whitespace and keyring in requirements sync to develop 2020-08-27 12:56:34 +01:00
Athanasius
364aaf2aef Merge branch 'develop' into main 2020-08-27 12:53:03 +01:00
A_D
d31b0fdbf6 Fixed system link updating on FSDTarget
FSDTarget contains the target system under `SystemAddress`, meaning that
any time you selected a star other than the current one, plugins'
`this.system_address` was updated to that target, rather than the
current system. Said updating causes the links provided from system_url
to reflect that update (for providers that support ID64s).

This changes the journal_entry behaviour to only update
`this.system_address` when the event is any of Location, Docked,
or FSDJump, all of which contain only the current system.
2020-08-27 11:32:39 +01:00
Athanasius
bd7a3eca04 plugins/inara: return '' if can't otherwise make system_url 2020-08-27 11:28:41 +01:00
Athanasius
113b6c427c station providers: Ensure the 'early station' functionality for all
* If you request docking successfully then show the station namd and
  have the link work.
* This is then only undone if you:
	1) Dock and undock
	2) Supercruise away
	3) Jump away
  It is *not* undone if you simply cancel the docking request.

Tested only with same provider for system and station for each of the
three, not the other 6 combinations.
2020-08-27 11:28:36 +01:00
Athanasius
daed08d206 system/station providers: Sanitise {system,station}_url logic
* Make all plugins use `requests.utils.requote_uri()`
* Make all plugins use roughly the same logic, without if/else trees
 (as the bodies do a `return ...`), ending with `return ''` if input
 parameters are None.

 This throws away the inara fallback to `this.station or this.system` as
 it's unlikely the in-plugin tracking did a better job than the
 monitor.py code.
2020-08-27 11:28:27 +01:00
Athanasius
7617ce7e9c system/station plugin providers: Don't override 'url'
By default the ttkHyperlinkLabels for 'system' and 'station' names have
their 'url' members set to the functions in EDMarketConnector.App.

The EDDB one used to override the function as it had to do that special
name -> EDDB ID lookup from systems.p.  When I changed the code to not
need that any more I didn't fully understand what these overrides were.

After updating the EDDB code I then made sure the same logic was also in
the other plugins which meant they *also* set static strings, overriding
the call to the EDMarketConnector.App functions (which chain through to
the current plugin providers).

Unfortunately I didn't quite update the EDSM code enough causing
journal_entry() code to *not* set a new system 'url' despite changing
the 'text'.  This meant that only CAPI updates (so docking and login)
caused the URL to change, despite updating the 'text' to the correct
system name.

Rather than have everything setting static strings just do away with the
overrides as they're not needed!
2020-08-27 11:25:30 +01:00
Athanasius
f75d8c9c9c plugins/edsm: Set system_link based on system_provider, not station_provider 2020-08-27 11:23:53 +01:00
A_D
d635bd8469
Fixed system link updating on FSDTarget
FSDTarget contains the target system under `SystemAddress`, meaning that
any time you selected a star other than the current one, plugins'
`this.system_address` was updated to that target, rather than the
current system. Said updating causes the links provided from system_url
to reflect that update (for providers that support ID64s).

This changes the journal_entry behaviour to only update
`this.system_address` when the event is any of Location, Docked,
or FSDJump, all of which contain only the current system.
2020-08-26 18:59:14 +02:00
Athanasius
8d6f761fb9 plugins/inara: return '' if can't otherwise make system_url 2020-08-26 12:01:45 +01:00
Athanasius
bf9d7dff89 station providers: Ensure the 'early station' functionality for all
* If you request docking successfully then show the station namd and
  have the link work.
* This is then only undone if you:
	1) Dock and undock
	2) Supercruise away
	3) Jump away
  It is *not* undone if you simply cancel the docking request.

Tested only with same provider for system and station for each of the
three, not the other 6 combinations.
2020-08-26 11:55:23 +01:00
Athanasius
c9dee18d70 system/station providers: Sanitise {system,station}_url logic
* Make all plugins use `requests.utils.requote_uri()`
* Make all plugins use roughly the same logic, without if/else trees
 (as the bodies do a `return ...`), ending with `return ''` if input
 parameters are None.

 This throws away the inara fallback to `this.station or this.system` as
 it's unlikely the in-plugin tracking did a better job than the
 monitor.py code.
2020-08-26 10:18:10 +01:00
Athanasius
d46358796f system/station plugin providers: Don't override 'url'
By default the ttkHyperlinkLabels for 'system' and 'station' names have
their 'url' members set to the functions in EDMarketConnector.App.

The EDDB one used to override the function as it had to do that special
name -> EDDB ID lookup from systems.p.  When I changed the code to not
need that any more I didn't fully understand what these overrides were.

After updating the EDDB code I then made sure the same logic was also in
the other plugins which meant they *also* set static strings, overriding
the call to the EDMarketConnector.App functions (which chain through to
the current plugin providers).

Unfortunately I didn't quite update the EDSM code enough causing
journal_entry() code to *not* set a new system 'url' despite changing
the 'text'.  This meant that only CAPI updates (so docking and login)
caused the URL to change, despite updating the 'text' to the correct
system name.

Rather than have everything setting static strings just do away with the
overrides as they're not needed!
2020-08-25 21:38:22 +01:00
Athanasius
669f895ffa plugins/edsm: Set system_link based on system_provider, not station_provider 2020-08-25 13:37:26 +01:00
Athanasius
c0ff2ff612
Merge pull request #658 from A-UNDERSCORE-D/cleanup/eddn
Cleanup eddn plugin
2020-08-19 11:14:24 +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