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

458 Commits

Author SHA1 Message Date
Athanasius
e6abc137ce
monitor/tracking: Shift .coordinates to state['StarPos']
* Some additional commenting for future clarity.
* Remove the old eddn.py tracking.
2023-01-11 19:43:18 +00:00
Athanasius
232e91ebfc
monitor/Body: Tweak & comment, and remove defunct tracking from eddn.py
* Typod '.status' instead of 'state'.
* Bring in some sanity-checks and comments from eddn.py to monitor.py.
* Have a 'pass' elif for 'supercruiseentry' so as to comment why we do NOT
  use this to blank out body state.
* Bring in the 'if we exit to main menu, blank body state' from eddn.py.
* Remove checks from eddn.py that are now in monitor.py.
* Have a disctinct 'docked' event check in eddn.py for triggering the
  "Now we're docked, so the Delay sending until docked is satisfied"
  sending of messages.
2023-01-11 19:43:17 +00:00
Athanasius
e3254aec31
monitor: Minor cleanup on 'Location'->'Docked' handling
* All my recent Location events *have* the 'Docked' flag.
* If any don't, then just use a default on .get() to set it False.
2023-01-11 19:43:16 +00:00
Athanasius
0177fc4d69
monitor: Remove .planet in favour of state['Body']
This had mostly been done already, now it's complete.

*If* any plugin is, still, using `monitor.planet` then they get to keep
the broken pieces because it's not included in PLUGINS.md#Available-imports.
2023-01-11 19:43:16 +00:00
Athanasius
9ccd0c3b7d
monitor: Remove EDLogs.systemaddress in favour of .state version
This was literally only used within this file.
2023-01-11 19:43:15 +00:00
Athanasius
86b0aa4550
monitor: Track all System and Body state in monitor.state
* Minor grammar edit only in PLUGINS.md (I was checking if it explicitly
  stated what data is expected in the synthetic 'StartUp' event, it doesn't).
* First changes to move some monitor properties into the monitor.state
  dictionary.  This is for system or body data.
* Re-factored the generation of 'StartUp' event into
  `EDLogs.synthesize_startup_event()`.  It's done in two places, so was
  anti-DRY.
* In general any bulk setting of system & body data is now done in the
  same order for comparison clarity.
* A little of the location tracking has been duplicated from plugins/eddn.py.
  This is with a view to switching *it* to using the state version.
2023-01-11 19:43:14 +00:00
Athanasius
6bd0b042b1
monitor.py: typing: Don't use List or Dict 2023-01-11 19:43:13 +00:00
Athanasius
6d6f3b057f
typing: Use | None, not Optional[...] 2023-01-11 19:43:12 +00:00
Athanasius
79bbc8917f
Move 'this is the GameVersion we found' logging to DEBUG
This quietens it for normal EDMC.py usage.
2022-12-14 10:51:37 +00:00
Athanasius
25ed649b7a
monitor/NavRoute: Load NavRoute after catching_up ends.
This is to allow restart of EDMarketConnector whilst the game is running
to have `state['NavRoute']` hold data when the synthetic `StartUp` event
is passed to plugins.

NB: Probably need to note this in PLUGINS.md
2022-12-06 15:34:12 +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
b3eff6ab32
monitor: Catch any failure to coerce gameversion
Also, log either the error or the success.  That will aid us in diagnosing
any future issues.
2022-11-27 13:02:54 +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
a2d2723f49
monitor: Add an 'IsDocked' flag to monitor.state.
* This is cleaner than starting to track it in `plugins/eddn.py` specifically.
* This is literally only about if we're piloting a ship that is docked, so
  not even trying to resolve "on-foot, in a station, 'Location' said not
  docked though".
2022-11-22 15:29:05 +00:00
Athanasius
ddba99bfd8
monitor: Handle NavRouteClear & un-() an assert
* Stop trying to load `NavRoute.json` if it contained a `NavRouteClear`.
* `assert` is a *keyword*, not a function.
2022-08-10 11:28:10 +01:00
Athanasius
8e8f09ade3
Journal: FCMaterials: Implement parsing separate file
This re-uses much of the NavRoute.json code, with a minor tweak to *not*
store the result in monitor.state, instead just returning it to caller.
2022-06-04 17:27:08 +01:00
Athanasius
9f08b003c5
monitor: __navroute_retry(): be less noisy
No need to log at INFO for the retry counts, as this appears to be working,
make it DEBUG instead.

This was making the EDMC.py output needlessly noisy.
2022-03-18 09:51:35 +00:00
Athanasius
c89548c2ba
monitor: journal_newest_filename(): Check for None directory
os.listdir(None) operates on '.', which is wrong in this context, so be
sure to avoid that.
2022-03-18 09:49:02 +00:00
Athanasius
4b12a6c484
monitor: Properly type new_journal_file
Python was guessing and not allowing 'None', which it will be at shutdown
if this code triggers.
2022-03-18 09:46:35 +00:00
Athanasius
04930c59ac
monitor: Properly determine *newest* Journal file
Using os.path.getctime for the order, not the filename.  This addresses the
changed Journal filenames in Odyssey Update 11, whilst keeping compatibility
with the Horizons Update 11 old-name-style filenames.
2022-03-15 16:08:18 +00:00
Athanasius
e17a40aaff
monitor: Change Journal file regex, because Frontier are being a PITA
They've changed it to an ISO8601 style full date/time now.  But the Odyssey
client still uses the old format.
2022-03-15 13:56:48 +00:00
Athanasius
46e914fcec
monitor: Revert state['StarSystem'] addition, it's not needed.
We pass `monitor.system` in to `journal_entry()` anyway, so it doesn't need
to be separately in the passed `state`.
2022-02-11 11:57:05 +00:00
Athanasius
f1ba8ee5e1
eddn: Fix up approachsettlement & adjust other such function signatures
1. We need StarPos (as well as StarSystem)
2. Adding more state tracking in this plugin is misguided.
3. So added it in monitor instead, putting *copies* of data in the
  monitor.state dictionary.
4. So we reference those, but only available in journal_entry() itself, else
  we'd need to pass the whole of `state` in.
5. So instead pass in the bits of `state` only when we need them.
2022-02-09 16:07:16 +00:00
Athanasius
f8e0fb3658
monitor: Fold 'EngineerCraft' to lower case in event_type comparison 2022-02-04 12:22:47 +00:00
Athanasius
5e612d56b3
Merge pull request #1411 from A-UNDERSCORE-D/sys-plaform-mypy
Ensure that platform guards are recognised by mypy
2022-01-27 12:58:26 +00:00
Athanasius
3a4690d292
monitor: Gate navroute on *not* being in journal catch up mode
We can't just use `EDLogs.live` here as it'll get set `true` when the
`Commander` event is seen *during the catch up*.  We need that catchup
to have finished before we'll try processing a `NavRoute` event and
file.
2022-01-26 17:29:29 +00:00
A_D
eb28a3b502
Use sys.platform, minor type updates 2022-01-26 18:51:41 +02:00
Athanasius
e98aec0169
monitor: Comment what MAX_NAVROUTE_DISCREPANCY is
So as to disambiguate from "some discrepancy within the route data".
2022-01-26 16:38:01 +00:00
A_D
62a0a96dc6
resolve final review comments 2022-01-26 17:42:50 +02:00
A_D
36ecb69964
refactor to use retry function for all attempts at navroute 2022-01-26 13:17:27 +02:00
A_D
06d4842da2
Be more parinoid about navroute files 2022-01-25 20:17:05 +02:00
A_D
d4c6cd94fe
retry navroute parsing after failure 2022-01-25 20:17:04 +02:00
Athanasius
8363e8c646
monitor: Don't re-init Enginers/Rank/Reputation on LoadGame
The order of Journal events changed from:

  1. LoadGame
  2. Rank
  3. Progress

to:

  1. Rank
  2. Progress
  3. LoadGame

in Odyssey, and in at least current 'base game' and Horizons clients as
well.  Also 'Reputation' event is before 'LoadGame' now.  So simply
allow those events to have populated the data, don't re-init on
LoadGame.

Yes, I'm preferring to leave the lines in, but commented, so it's clear
why those aren't being init'd, *and* why 'Statistics' still is, and as
of what game version.
2021-11-21 11:24:18 +00:00
Athanasius
919136874d
CAPI: Re-auth when Access Token expired: Need to .close() first
The old code did this, and without it we enter a loop of:

1. CAPI says unauthorized
2. We call login()
3. But companion.session.state == STATE_OK, so do nothing
4. Re-scheduled CAPI request goes back to 1.
2021-11-06 08:41:09 +00:00
Athanasius
2754385281
monitor: Use trace_if('journal.startup', ...) for game load-in 2021-08-13 15:14:03 +01:00
Athanasius
1378f765cc
monitor: Convert to logger.trace_if() 2021-08-13 15:14:02 +01:00
A_D
05e6838637
removed trace_on imports 2021-08-12 16:49:27 +02:00
A_D
fefa3d351d
replaced if x in trace_on with trace_if 2021-08-12 16:46:55 +02:00
Athanasius
97808f5561
monitor.py: Access trace_on via whole-config import
This is necessary so as to see the same instance of config.trace_on as
is set up by EDMarketConnector.py.
2021-08-11 12:33:22 +01:00
0bb06232b8
monitor.py: add default value to entry.get('GameMode') in CQC detection 2021-08-11 14:24:27 +03:00
bd32b44903
monitor.py: fix CQC to lower case 2021-08-11 13:50:09 +03:00
42ce2ad414
monitor.py: trace loadgames to CQC only if in trace_on 2021-08-10 14:27:47 +03:00
7b823dd64d
Remove commented out logger.debug() 2021-08-10 03:16:57 +03:00
e9ee65da14
Code style fix 2021-08-10 03:15:50 +03:00
3283439485
Code style fixes 2021-08-10 03:00:36 +03:00
a00a677746
monitor.py: use trace instead debug to log CQC loadgames 2021-08-10 02:49:58 +03:00
d7dd8c8990
Be more paranoid with GameMode and CQC 2021-08-09 17:15:54 +03:00
291fbf2908
Use both Ship and GameMode fields of LoadGame event to detect CQC
And freeze update button when in CQC
2021-08-09 15:59:30 +03:00
27fe43bf8c
WIP: implement journal_entry_cqc()
journal_entry_cqc function in plugin's api allow plugins to recieve
journal events when player are in CQC
2021-08-09 04:37:23 +03:00
Athanasius
cc6b52a9ed
Shiplocker: while/else a failure logging 2021-08-07 14:45:46 +01:00