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

744 Commits

Author SHA1 Message Date
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
A_D
b5d3b89a3c
Added docstrings and further type annotations 2020-08-07 14:39:12 +02:00
A_D
265faf3cdd
Reordered imports 2020-08-07 13:45:06 +02:00
A_D
3155b929fa
Fixed docstring on Credentials, log wording 2020-08-07 13:37:19 +02:00
A_D
d5dd23ce38
Missed an add_event call 2020-08-07 13:34:31 +02:00
A_D
dd85fc0504
Rewrote inara queue system
This replaces the list+queue system that the inara plugin originally
used with a deque based one.

The main differences here are that the list the worker thread uses to
send to inara and the list that events are added to is the same, with
the worker thread making a duplicate and clearing the original each time
it sends events (losing events if it fails to upload three times).

The format of the data has changed as well, from simple tuples to
NamedTuple classes that provide some extra type safety and sanity when
accessing fields.

The event queue itself is actually multiple queues, one per
API/FID/CMDR_name triplicate, thus allowing multiple commander switches
while we're running without causing any weird issues
2020-08-07 13:34:30 +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
513e21a06e Inara timer fix.
I had to pull a diff out of the old branch, apply it, and reverse things
like the addition of logging.  This needs to be the minimum change for
the fix.

Tested with a quick login, then spamming market buy/sell orders.  They
were correctly queued and then sent after 30s since previous API calls.
2020-08-02 19:35:02 +01:00
A_D
81dfbdfb8e
Added timeout_session, made inara use it
timeout_session provides two things, TimeoutAdapter, a HTTP adapter
subclass that automatically adds timeouts to all requests, and
new_session, which automatically creates a request.Session with the
adapter in the correct place.
2020-07-31 15:53:20 +02:00
A_D
21a285e6e9
added some more type hints 2020-07-31 15:47:28 +02:00
A_D
f8d4731472
fixed incorrect indexing 2020-07-31 15:47:27 +02:00
A_D
eba318430a
Removed todos about unused args 2020-07-31 15:47:27 +02:00
A_D
446c812485
replaced oneline logic with multiline 2020-07-31 15:47:26 +02:00
A_D
67a260c07f
added type hints to literals 2020-07-31 15:47:26 +02:00
A_D
9005798862
fixed incorrect comment 2020-07-31 15:47:25 +02:00
A_D
bb1def48cd
replaced list comp with filter 2020-07-31 15:47:25 +02:00
A_D
a699ab062d
fixed station link logic 2020-07-31 15:47:24 +02:00
A_D
e74c5c8ceb
replaced list comp with filter 2020-07-31 15:47:23 +02:00
A_D
820b29f7dd
replace dict(list-comp) with dict comp 2020-07-31 15:47:23 +02:00
A_D
539580e38d
Consistently formatted multi-line add_event calls 2020-07-31 15:47:22 +02:00
A_D
96279cb0af
Replaced repeated entry['event'] with variable 2020-07-31 15:47:21 +02:00
A_D
71ad0f92ac
removed outdated comment 2020-07-31 15:47:21 +02:00
A_D
8e49066ca4
Replaced convoluted or-based logic with terneries 2020-07-31 15:47:20 +02:00
A_D
9db9ed4dfc
Cleaned up overlong lines 2020-07-31 15:47:19 +02:00