1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 08:17:13 +03:00

715 Commits

Author SHA1 Message Date
Athanasius
3f91e57c7c
plugins/eddb: Fix journal_entry() and new_data types
plug.py does `dict(entry)` before calling a plugin's `journal_entry()`, so
`dict` is correct for `data`.  Thus also use that for `new_data`'s type.
2022-12-30 16:34:17 +00:00
aussig
41962663d8 Merge branch 'develop' into feature/847/capi-fleetcarrier 2022-12-24 08:21:18 +00:00
Athanasius
5e19d3e9aa
plugins/eddn: No need for typing.(Dict|List) usage 2022-12-23 14:47:40 +00:00
Athanasius
ce4a6ff898
plugins/eddn: Remove the 'default values' from should_retrn & new_data
In *this* case the variables *are* used in the scope so become bound, so
we can get away with bare type declaration.
2022-12-23 14:47:26 +00:00
Athanasius
2c11aef1be
plugins/eddn: Use correct logging function & new_data typing
* `logger.INFO` will, at best, be a constant, it should be `logger.info()`.
* When we're not interested in the `new_data` 2nd part of the tuple from
  `killswitches.check_killswitch()` we can't use `_` as there's a potential
  class with the `l10n.py` injection of `_()` as a builtin.

  And you can't declare types withing first-use in a return-tuple. So, declare
  them on their own lines, with throwaway default values instead.
2022-12-23 14:47:25 +00:00
Athanasius
e66bae090b
plugins/inara: Minor typing fixes 2022-12-23 14:47:24 +00:00
Athanasius
71cbfb8358
plugins/edsm: Lots of type fixing, inc. conditionals where None is possible 2022-12-23 14:47:23 +00:00
Athanasius
ca233a40a8
plugins/coriolis: Minor type fixes. 2022-12-23 14:47:22 +00:00
Athanasius
26b12f5b14
plugins/inara, plug.py: Minor typing fixes 2022-12-23 14:47:18 +00:00
aussig
3e295db061 Typing of return values from killswitch.check_killswitch() 2022-12-22 17:39:20 +00:00
Athanasius
868c1d8e57
docs: Fix up references to setup.py to be to Build-exe-and-msi.py 2022-12-20 16:51:58 +00:00
Athanasius
ba68397b3f
CAPI killswitches: endpoint killswitches & eddn export ones too
* Added `capi.request.<endpoint>` killswitches at appropriate call points.
* Added `eddn.capi_export.<type>` killswitches.  This allows for killing
  just the EDDN export of such CAPI-derived data, without stopping the actual
  queries, as other plugins/functionality might still have harmless use of
  the data.
* PLUGINS.md: Actually describe the contents of `data` passed to plugins, and
  point out it might not always contain market or shipyard data.  This is
  not only because of the new killswitches, but could already have happened
  if the station/port docked at didn't have the services.
* Some misc typing cleanups.
2022-12-16 15:06:01 +00:00
Athanasius
e245a75e61
EDMC: Get -n working again
* eddn: Don't schedule `queue_check_and_send()` if EDMC_NO_UI.
* `export_(commodites|outfitting|shipyard)` lost the `is_odyssey` argument
 in 556ace5306bebbcf34c1a56a9023a822218a73f1 .
* EDDNSender: Helper `set_ui_status()` in which the check for EDMC_NO_UI
  is performed.  Used in `send_message()`.  In the EDMC_NO_UI case it will
  INFO log the text instead.
2022-12-14 11:15:20 +00:00
Athanasius
0915bad95d
CAPI/EDDN: Enable sending of Legacy data
As we already took some care in the EDDN code we can just make
`cmdr_data_legacy()` call through to `cmdr_data()`.
2022-12-08 12:10:15 +00:00
Athanasius
38c2f19474
eddn: Suppress "converted file" for legacy if no file
This was a total brainfart, `finally:` is never what was wanted here.
So, just `return` if `FileNotFoundError`.
2022-12-05 16:40:44 +00:00
Athanasius
6bd48a163c
eddn: Ensure CAPI-sourced messages have uploaderID set
If no 'live' Journal events yet, plugins/eddn won't have had an event to set
this from.
2022-12-05 15:53:27 +00:00
Athanasius
a6f9a31fd9
plugins/edsy: flake8 and mypy pass 2022-12-04 16:20:08 +00:00
Athanasius
ba81d95c1e
plugins/edsm: Align comments and docstrings with plugins/eddb 2022-12-04 16:12:58 +00:00
Athanasius
73c4bcfcc7
plugins/eddb: flake8 & mypy now clean
* Converted to `class This` paradigm.
2022-12-04 15:57:09 +00:00
Athanasius
62ed12eba3
plugins/eddb: flake8 pass 2022-12-04 15:36:00 +00:00
Athanasius
abe13176e7
EDSM: Timed latch for notifying about Legacy galaxy data
This avoids the spam from EDSM itself objecting to the passed gameversion.
We don't even send anything but Live data now.
2022-12-01 18:00:47 +00:00
Athanasius
db4f59dd16
Inara: Remove the "update 14 date passed?" check
- We're now past there and no-one should expect that messing with their clock
  will bypass this check.
2022-12-01 17:43:31 +00:00
Athanasius
b4c4e44cb7
eddn/CAPI: Use a common function for game_version strings
* This did, however, remind me that the `data` passed into `cmdr_data()`
  is an amalgam of `/profile`, `/market` and `/shipyard` queries.

  This means that the data.source_endpoint is **not correct for all of
  the data and its use**.  As such I had to pass 'hard coded' values into
  the function from the various CAPI export functions.  They know what it
  is they're exporting.

* As this reminded me that "CAPI `data` is actually a `CAPIDATA`", I've
  documented that in PLUGINS.md, but with a dire warning against relying on
  any of the extra properties.
2022-12-01 16:42:06 +00:00
Athanasius
b40d3b889f
CAPI: Use CAPI-Live-<endpoint> game_version for market & shipyard 2022-12-01 16:42:05 +00:00
Athanasius
4a8b5ed4b6
Merge pull request #1735 from EDCD/fix/1732/inara-do-not-send-empty-required
Inara: Drop various combat messages if empty opponentName
2022-12-01 16:41:32 +00:00
Athanasius
26413177a6
Inara: Also check opponentName on EscapeInterdiction
And sprinkly comments around giving a reason for the checks.
2022-12-01 13:45:10 +00:00
Athanasius
aac660fb05
Inara: Also catch empty opponentName for Interdict*ion* 2022-12-01 13:37:56 +00:00
Athanasius
2bbda30097
Inara: Drop addCommanderCombatInterdicted if empty opponentName
Addresses #1732 specifically.

At some point #1433 needs fully addressing (review all Inara API code for
compliance with docs).
2022-12-01 13:33:26 +00:00
Athanasius
e86110a3da
inara: Only warn for 'Legacy' if data would have been sent
* Specifically, only warn if the user option to send to Inara is active.
2022-11-30 12:07:48 +00:00
Athanasius
3f0aefd671
eddn: Fix spelling mistake in a log message 2022-11-28 15:38:34 +00:00
Athanasius
ab9e5f7278
Merge branch 'enhancement/1719/edsm-api-gameversion-gamebuild' into release-5.6.0-beta1 2022-11-28 12:20:36 +00:00
Athanasius
a581d889fe
edsm: Add a paranoia check for changed gameversion
* In theory we would always see `Fileheader` and clear `pending[]`, but let's
  be extra paranoid and also clear it if there's a gameversion/build difference
  between the prior event and the current one.
2022-11-28 12:18:10 +00:00
Athanasius
5743fd3803
edsm: Push gameversion/build into the queue to ensure correctness
1. Due to the _TIMEOUT on the actual `post()` of a message it would be
  possible for new entries to get queued in the meantime.  These queued
  entries could be 'in session' and end up going through pending and thus
  sent before one of the 'new session' events is detected so as to clear
  pending.  The `this.gameversion/build` could have changed in the meantime,
  so are no longer correct if game client changed.
2. So, pass in the current gameversion/build when a message is pushed into
  the queue, and parse those back out when they're pulled out of the queue.
3. Use those versions in the message, not `this.` versions.
2022-11-28 11:04:51 +00:00
Athanasius
ad95041605
edsm: Send gameversion/build in all messages
* Record the 'state' version of these in `this`.
* Use those when constructing the message.
* NB: Need to check if messages can be retained in the queue across client
  changes.  Coming up ....
2022-11-28 10:51:25 +00:00
Athanasius
2ac8026e3e
eddn: Allow for '' in standard_header()
`''` is Falsey, but a valid value, so we need an explicit `is not None`
test for these.
2022-11-27 17:01:28 +00:00
Athanasius
d902093f0b
Merge pull request #1682 from EDCD/fix/1431/eddn-replay-enhancements
Change EDDN 'replay' to using an sqlite3 DB & otherwise improve
2022-11-27 15:24:28 +00:00
Athanasius
8a58220a66
inara: Send only Live galaxy data after Update 14
* Adds `monitor.is_live_galaxy()` for general use.
* Assumes Update 14 starts after 2022-11-29T09:00:00+00:00.  That's the
  currently schedule day, and recently the servers have been down by the time.
  Likelihood of them coming back *up* quickly seems slim to none.
* If we couldn't parse the `gameversion` from Journal using
  `semantic_version.Version.coerce()` this will fail, and assume we're on
  the Legacy galaxy.
2022-11-27 12:47:19 +00:00
Athanasius
345938a81d
eddn: Set gamebuild="" for CAPI-sourced data
Whilst setting it to the same "CAPI-<endpoint>" string as `gameversion` in
these cases would probably be OK, that's not the intent of the EDDN
documentation, which has now been clarified.
2022-11-25 15:45:07 +00:00
Athanasius
073afc842f
eddn: New --trace-on plugins.eddn.send & other logging tweaks
* In case of apparent issues, have a `--trace-on` to better see what's (not)
  happening.

  All the old DBEUG logging, even if commented out, is now under this.
* Also added some INFO level logging for the legacy replay.jsonl conversion,
  as it should be one-time per user.
* Some additional DEBUG logging for closing down.
2022-11-24 14:09:57 +00:00
Philipp Trulson
c8e00304fb
Fix URL for EDDN GitHub Link 2022-11-24 14:09:43 +01:00
Athanasius
32229217b2
eddn: Bail from sending queued messages if one failed
NB: This is failed *not* due to the message being 'bad' in some manner. It
will mean the Gateway timed out, refused connection etc.
2022-11-23 16:00:28 +00:00
Athanasius
95fa9d577c
eddn: Use a shorter, 10 second, delay at startup for first queue check 2022-11-23 14:20:24 +00:00
Athanasius
3d9bb64330
eddn: Remove outdated comment about replaylog rework
And using tk `parent` *is* absolutely necessary.
2022-11-23 14:12:43 +00:00
Athanasius
b7769821be
eddn: Send immediately if docked
This has the "are we delaying sending?" check, but without the short-circuit
for "we are actually docked right now".
2022-11-23 13:56:01 +00:00
Athanasius
524c0425fb
eddn: EDDN.send_message(): Only set standard header if not already set.
Else we risk overwriting e.g. `CAPI-shipyard`.
2022-11-23 13:46:49 +00:00
Athanasius
fda91df04f
eddn: Working with tk after(), on timer or when docked
* An aborted attempt was made to use a thread worker, but:
  1. sqlite3 doesn't allow cross-thread use of the same sqlite3 connection.
  2. Having an on-going query on one cursor, e.g. gathering all the
    outstanding message `id`, whilst trying to DELETE a row hits a
    "database is locked" error.
* So, back to tk `after()`.  `send_message_by_id()` has been audited to ensure
  its boolean return is accurate.  So there shouldn't be any way in which to
  get hung up on a single message *other than if the EDDN Gateway is having
  issues, and thus it should be retried anyway*.  Any reason for a 'bad
  message' will cause `True` return and thus deletion of the message in
  *this* call to `queue_check_and_send()`.
* There is a new `reschedule` parameter to `queue_check_and_send()`.  If
  `True` then at the end it should re-schedule.

  There is a check in `journal_entry()` for the `Docked` event, and if this
  occurs it will schedule `queue_check_and_send()` with `reschedule` set to
  `False` so that we don't end up with multiple parallel schedulings.

  It's still possible for a docking to have coincided with a scheduled run
  and thus cause double-rate sending to EDDN, but we can live with that.

* The same scheduling mechanism is used, with a much smaller delay, to
  process more than one queued message per run.

  Hence the `have_rescheduled` bool *in* the function to indicate if a 'fast'
  reschedule has already been set.  This prevents the slow one *also* being
  set in this scenario.  The latter will be scheduled when the fast one
  found no more rows to process.
2022-11-23 13:29:47 +00:00
Athanasius
f2dbfacf70
eddn: Add header for CAPI outfitting and shipyard exports 2022-11-22 17:40:33 +00:00
Athanasius
f6e2504216
eddn: Fix capi_fcmaterials gameversion/build & add to CAPI commodity
* Erroneously used 'CAPI-commoodity' when it's 'CAPI-market' (name of the
  CAPI endpoint, not anything to do with EDDN schema names, and '-commodity'
  would also be wrong for that).
* Set `header` for (CAPI) `export_commodities()`.
2022-11-22 17:37:15 +00:00
Athanasius
b31c8c0536
eddn: A start on ensuring header (gameversion/build) are always set 2022-11-22 17:35:17 +00:00
Athanasius
4a0518da9f
eddn: Set header up properly for all journal messages
* New function `EDDN.add_header()`.
* It utilises new `this` members, set from `journal_entry()`.
2022-11-22 17:26:32 +00:00