Commit Graph
615 Commits
Author SHA1 Message Date
Athanasius 06fa3629ea eddn: OUT_EDDN_DELAY (not inverted) & further work on the sending
* The eddn parts of the OUT_EDDN_DO_NOT_DELAY -> OUT_EDDN_DELAY change.  This
  includes the 'sense' of it being inverted from what it was.
* EDDN.REPLAY_DELAY is now a float, as it's used with `time.sleep()`.  *This*
  is the 400ms value for inter-message cooldown.
* EDDN.REPLAY_PERIOD is still an int, used with tk `after()`.  This is how
  often we attempt the queue.
* EDDN.session is no longer a thing, move that part of EDDN.close() to
  EDDNSender.close().
* EDDN queue DB has `id`, not `message_id`.
* Now *looping* in the queue sender, not only sending the oldest message.
2022-11-22 16:49:02 +00:00
Athanasius 59f046ee67 eddn: First cut of periodic retry of sending messages 2022-11-22 15:51:10 +00:00
Athanasius 876c34ecfd eddn: Remove two 'noqa: CCR001' that are no longer applicable 2022-11-22 14:09:08 +00:00
Athanasius 06edcf3ea9 EDDN: Remove EDDN.send() in favour of renamed .export_journal_entry()
* Now that we're not trying to do "did we just/are we know docked?" in this
  code it turns out that both CAPI and Journal messages can use the same
  function for this.
* And as it's no longer journal-specific `EDDN.export_journal_entry()` has
  been renamed to `EDDN.send_message()`.

This whole branch now needs to actually implement sending queued messages
when docked, and periodically in the case of initial failures.
2022-11-22 14:02:21 +00:00
Athanasius fe24cf7e95 EDDN: Remove legacy sendreplay()
* `EDDN.sendreplay()` is no longer used.
* In `prefsvarschanged()` there was a reference to `eddn.replayfile`, so as
  to grey out the "Delay sending..." option if the file wasn't available.
  So that's moot and also removed, but also...
* Comment the purpose of that line in `prefsvarchanged()` because it's not
  immediately obvious.
2022-11-22 14:02:20 +00:00
Athanasius db7bb735d2 EDDN: Put "should we send (now?)" checks into EDDN.export_journal_entry()
In some cases the check might already have been done, but if not then this
is the last easy place to perform it.

NB: Unlike the old code this does *not* attempt to check "are we docked
  *now* ?" for triggering sending of previously queue messages.  That's
  going to need a thread worker.
2022-11-22 14:02:19 +00:00
Athanasius 03b36cbe39 EDDN: Improve export_journal_fcmaterials "don't send" comment 2022-11-22 14:02:18 +00:00
Athanasius 5eb4296ec6 EDDN: First steps to ensure new code respects user configuration
It's easier to check "should we send this message at all?" earlier. Currently
all of the following ('station data') do so:

* CAPI commodity, outfitting (also fcmaterials) and shipyard.
* Journal commodity, fcmaterials, outfitting,  and shipyard.
2022-11-22 14:02:17 +00:00
Athanasius 7d0ae88757 EDDN: EDDNSender.send_message() doesn't care about do/don't send options
By this point other code will have made that decision.
2022-11-22 14:02:16 +00:00
Athanasius 0d35f8874a config/EDDN: Rename OUT_MKT_EDDN to OUT_EDDN_SEND_STATION_DATA
This flag controls whether commodity, outfitting or shipyard schema messages
are sent.  Thus 'MKT' ('market') is misleading.  Rename it so the intent when
used is clear.
2022-11-22 14:02:15 +00:00
Athanasius 9f02f18408 config/EDDN: Rename OUT_SYS_EDDN to OUT_EDDN_SEND_NON_STATION
* This was perhaps originally meant for what the UI option says, i.e. "send
  system and scan data", but is actually being used for anything that is
  **NOT** 'station data' (even though *that* option has 'MKT' it includes
  outfitting and shipyard as well).

  So, just name this more sanely such that code using it is more obvious as
  to the actual intent.
2022-11-22 14:02:14 +00:00
Athanasius 3a57b53bbd config/EDDN: Rename OUT_SYS_DELAY to OUT_EDDN_DO_NOT_DELAY
The sense of this `output` flag has been inverted (always?) for a long time.

1. I have the option "Delay sending until docked" showing as *off* in the UI.
2. My config.output value is `100000000001`.
3. The value of this flag is `4096`, which means 12th bit (starting from 1, not
  zero).
4. So I have the bit set, but the option visibly off.

So, rename this both to be more pertinent to its use *and* to be correct as to
what `True` for it means.
2022-11-22 14:02:13 +00:00
Athanasius 598e54eaa4 EDDNSender: Now properly sends messages to Gateway
Including removing from the queue if it succeeded, or didn't and should be
dropped.
2022-11-22 14:02:12 +00:00
Athanasius f66a98464e EDDNSender: Closer to actually sending messages now 2022-11-22 14:02:11 +00:00
Athanasius 2b957d140c EDDNSender: convert_legacy_file() belongs with "open the database" 2022-11-22 14:02:10 +00:00
Athanasius 0e20f4bc00 EDDNSender: Remove legacy file after migration 2022-11-22 14:02:09 +00:00
Athanasius f3017d40ec EDDNSender: Fill out type hints 2022-11-22 14:02:08 +00:00
Athanasius 51fb90b999 EDDN: Change EDDN.close() to call into EDDNSender.close() 2022-11-22 14:02:07 +00:00
Athanasius c1793ad839 EDDN: Remove EDDN->flush() 2022-11-22 14:02:06 +00:00
Athanasius 09f646a249 EDDNSender: Add delete_message() method
This was tested by temporary code in `convert_legacy_file()` to delete
the last added row once all done.
2022-11-22 14:02:06 +00:00
Athanasius 86ff787aed EDDNSender: Convert all of a legacy file
* I had a `break` in there to only convert the first message.
* Also collapsed the assignment to `cmdr, msg` to not go via `j`.
2022-11-22 14:02:05 +00:00
Athanasius 089c33002c EDDNSender->add_message() returns ID of INSERTed row 2022-11-22 14:02:04 +00:00
Athanasius 80129361fe EDDN: Refactor queue db open/creation to own function 2022-11-22 14:02:03 +00:00
Athanasius 9a660b3b49 EDDN: New class as EDDNSender now, and version the queue database file
* It makes more sense for this new class to be concerned with all the 'send it'
  functionality, not just 'replay', so rename it.
* Athough we're trying to get the schema right *first* time, let's plan ahead
  and version the filename in case of needing to migrations in the future.
2022-11-22 14:02:02 +00:00
Athanasius 424d5f023c EDDNReplay.add_message() is now functional
And that includes the code to handle legacy `replay.json` messages.
2022-11-22 14:02:01 +00:00
Athanasius 03e432034f EDDN: Moving replay functionality into its own class 2022-11-22 14:02:00 +00:00
Athanasius 072eadd893 EDDN: messages.id AUTOINCREMENT, and index created & cmdr
We'll definitely want to query against `cmdr`, and possibly `created`.

We shouldn't need to against other fields, they'll just be checked during
processing of an already selected message.
2022-11-22 14:01:59 +00:00
Athanasius 9faae8b9bc EDDN: Open & create sqlite3 db for replay
* sqlite3 open, and creation of table.
* Change `load_journal_replay()` to `load_journal_replay_file()` and change
  the semantics to just return the `list[str]` loaded from it.  It also now
  catches no exceptions.
* Remove the "lock the journal cache" on init as it's not necessary.

There's still a lot more changes to come on this.
2022-11-22 14:01:58 +00:00
Athanasius e530544ac5 eddn: fcmaterials: Now working for the two separate schemas 2022-09-02 17:27:16 +01:00
Athanasius 69ef3b7d39 eddn: fcmaterials: Actually send horizons and odyssey flags for CAPI data 2022-08-31 16:34:21 +01:00
Athanasius c77576f3d4 EDDN: fcmaterials/1 from CAPI /market data 2022-08-31 15:59:34 +01:00
Athanasius 37553d6bc7 EDDN: Add 'data-source' to Journal FCMaterials export 2022-08-31 15:19:54 +01:00
Athanasius a61829eaf7 EDDN: Implement Journal-based fcmaterials/1 schema
The EDDN schema is still a work in progress, unsure if we'll use the same
one for both Journal and CAPI sourced data, or separate schemas.

But, so far, this works.
2022-08-30 17:17:00 +01:00
Athanasius 5fa9bcd48e inara: Wrap the <var> := <dict get> in () so <var> isn't a bool
Because, yes, 'is not' binds more tightly than ':='.
2022-08-13 18:34:28 +01:00
Athanasius 7b47dab543 inara: ApproachSettlement: Only set marketID if present in event
At least 'Ancient Ruins' generate an `ApproachSettlement` event without a
`MarketID` in the event.  Not even a key with `null` value.
2022-08-12 13:57:31 +01:00
Athanasius f28228285a plugins/eddn: Do *NOT* alert user on 'no Route in NavRoute'
This can simply occur if the *first* load of `NavRoute.json` soft-fails,
meaning the plugin is receiving the bare Journal-file event, which has no
`Route` array.
2022-08-10 11:51:23 +01:00
Athanasius 9162b3a94d eddn/fsssignaldiscovered: For Horizons add check on tracked location 2022-06-23 10:34:13 +01:00
Athanasius e38ce639f0 eddn/fsssignaldiscovered: Catch where no signals pass checks
Else we attempt to send an empty `signals` array, which the schema prohibits.
2022-06-19 11:47:24 +01:00
Athanasius c5f53a8378 Merge pull request #1587 from chennin/EDMarketConnector-1496-EDSM-log-2
Change EDSM credentials() to log API keys under a different trace #1496
2022-06-17 12:52:38 +01:00
Athanasius 57953ef3f2 EDDN: Ensure *all* _Localised key/values removed
This has been missed, based on Journal examples, and has been causing issues
at least for `ApproachSettlement`.

So, `filter_localised()` now used in:

    `export_journal_navroute()`
    `export_journal_approachsettlement()`
    `export_journal_fssallbodiesfound()`
2022-06-17 12:46:46 +01:00
Athanasius 77203c7227 eddn/fsssignaldiscovered: Misc fixups
* Need to remove `event`, `horizons` and `odyssey` per signal.
* It's lower case `horizons` and `odyssey` in a(n augmented) journal event.
* It's `event`, not `entry` that `export_journal_entry()` will look for.
2022-06-15 14:34:06 +01:00
Athanasius 37c88aeefc eddn/fsssignaldiscovered: Further cleanup
* Move call to `export_journal_fsssignaldiscovered` to top-level of event
  processing.  This ensures we'd still have the *previous* system tracked
  when running under Odyssey.

  Also, we can't return any result from this, as we'd still need to process
  things like `Location` otherwise.
* Use `logger.trace_if("plugin.eddn.fsssignaldiscovered", ...)`
* Perform all sanity checks, elisions and augmentations in the "not
  FSSSignalDiscovered event" sending code.
2022-06-15 13:19:13 +01:00
Athanasius d5ec54dbea eddn/fsssignaldiscovered: Start on cleaning up chennin's work 2022-06-15 12:11:01 +01:00
Chris Henning afda16853b Change this log to debug level 2022-06-12 17:59:18 -04:00
Chris Henning e8b8cf81d5 Change EDSM credentials() to log API keys under a different trace #1496 2022-06-12 17:51:38 -04:00
Chris Henning 4bf2965cc5 remove unnecessarily committed debug messages 2022-06-12 17:12:08 -04:00
Chris Henning 4dfcd91bcd fix more flake8 errors 2022-06-12 16:19:25 -04:00
Chris Henning 1b37991016 fix flake8 errors 2022-06-12 16:16:54 -04:00
Chris Henning df9f0bfc7c Implement FSSSignalDiscovered sender v1 2022-06-12 15:26:50 -04:00
Athanasius 52cc71a217 eddn: Clear bodyname/id on supercruiseexit, if at orbital station 2022-06-05 15:31:28 +01:00