Commit Graph
124 Commits
Author SHA1 Message Date
A_D 278480b99f replaced ors with defaults in config usage 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 bd670b7ff1 Updated plugins to expect that CAPI data is safe
# Conflicts:
#	plugins/eddn.py
2021-04-01 14:45:45 +01:00
Athanasius 9b09d8bd07 plugins/inara: Close down logging & Remove unused this.queue.
* The new_worker/NewThis doesn't currently have a mechanism to ask the
 new_worker to exit.  It's relying on being a daemon thread and dying
 once all non-daemon (i.e. main) threads have exited.
2021-04-01 14:45:44 +01:00
Athanasius aab2a58a2d Reduce some log spam:
* Comment out the traceback in plugins/eddn.py, the return is enough.
* 'Called with no event_queue' can be TRACE.
* Don't care about "Everything was alright, the near-neutral status just
  wasn't stored." from Inara.
2021-03-23 13:48:44 +00:00
Athanasius 462cd25312 config: Make config.shutting_down() a property, and change 'callers' 2021-01-11 16:54:09 +00:00
Athanasius 111f445cac plugins/inara: Avoid Tk event_generate() calls during shutdown 2021-01-11 16:45:45 +00:00
Athanasius a3b69fd94d Switch internal plugins to EDMCLogging.get_main_logger() 2020-09-22 16:20:05 +01:00
A_D 6fc2ab063e finished type annotation 2020-09-18 07:28:30 +02:00
A_D 5af2511137 Updated docstrings 2020-09-18 06:44:20 +02: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
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
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
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
A_D 13c2679c38 Added spacing around scope changes 2020-07-31 15:47:19 +02:00
A_D 160013e3e5 Added type annotations and docstrings 2020-07-31 15:47:18 +02:00
A_D eec4c2ebd6 autoformat with autopep8 2020-07-31 15:47:18 +02:00
A_D ce4149efd5 Added debug logs 2020-07-29 14:58:17 +01:00
A_D d4299c224f dont force a send on exit
just try and send if we can
2020-07-27 15:12:32 +02:00
A_D bb817eee3b removed outdated comment 2020-07-27 15:08:47 +02:00
A_D 340f8928b3 switched to using config for last update time 2020-07-27 15:08:47 +02:00