Commit Graph
809 Commits
Author SHA1 Message Date
David Sangrey 075bfba909 Rename Avail Trace File 2026-01-27 23:36:05 -05:00
David Sangrey 90701d9edb [#2583] Extra Guarding Around Git Commands 2026-01-27 23:09:45 -05:00
David Sangrey 2ea4382958 [#1438] Add Trace Help Opener 2026-01-27 19:39:13 -05:00
David Sangrey 2f573b425c [#2600] Ensure File Update on Boot 2026-01-25 10:44:58 -05:00
David Sangrey cb93822470 Update Docs Pass 2026-01-19 12:22:24 -05:00
David Sangrey 5ea845c3ac Update for New Enum 2026-01-04 20:05:34 -05:00
David Sangrey f345dc6715 [#559] Prevent EDMC Crash -> No Update 2026-01-03 21:21:12 -05:00
David Sangrey f69a45584f Linter Fixes from #2553 2026-01-02 22:42:39 -05:00
David Sangrey ecff305ef8 Merge branch 'develop' into develop 2026-01-02 22:24:18 -05:00
David Sangrey 913a2340a7 Fix Merge Issues 2026-01-01 22:34:59 -05:00
David Sangrey dc270d66c1 Merge branch 'develop' into enhancement/plugin-browser 2026-01-01 21:58:46 -05:00
David Sangrey 726fbbdb34 [Minor] Don't Allow Negative Resizing 2026-01-01 21:13:42 -05:00
David Sangrey 215fc01dcb Type Hints 2026-01-01 20:45:39 -05:00
David Sangrey 2e54b1042a [#478] Try a Different Tactic 2026-01-01 20:38:43 -05:00
David Sangrey dc80dc679e [#478] Attempt Resizing Allowance 2025-12-28 21:27:06 -05:00
David Sangrey 8247857ab9 [Minor] Add Updates to Main Appwindow Init 2025-12-27 23:23:36 -05:00
David Sangrey deb094636f Merge pull request #2537 from inutt/fix/2286/plugin-events-before-loadgame
Send journal events to plugins from before 'LoadGame' has been parsed
2025-12-27 14:28:18 -05:00
David Sangrey 678ab38ad9 [Minor] Remove Unneeded File Check 2025-12-26 23:19:10 -05:00
David Sangrey f61b319fcd [#2570] Datafile Updater 2025-12-25 02:27:12 -05:00
David Sangrey beb68efae8 [2568] Fix Ships JSON Typo 2025-12-25 01:36:24 -05:00
TwokSSEi eff8d7f947 Merge branch 'develop' into develop 2025-12-12 23:28:05 -05:00
rinkulu 3693c08a0d [Bugfix] Fix type mismatch when reading certain boolean config values 2025-12-08 07:11:59 +03:00
TwokSSEi f6ea33c8bb [Proposal ]Market Export Choice of Text Data format 2025-12-07 21:51:37 +00:00
David Sangrey ab5c8ac6c6 [2440] Fix Updater Race Condition 2025-12-07 14:05:48 -05:00
David Sangrey da08d5adfb [Minor] Linters gonna Lint 2025-12-06 23:55:33 +00:00
David Sangrey f8d021e58c [PRE-RELEASE] 6.0.0-RC1 2025-12-06 23:50:44 +00:00
David Sangrey 8bd423701e Merge branch 'develop' into main 2025-12-05 19:18:16 -05:00
dwomble a27054c1a7 Merge branch 'EDCD:main' into main 2025-12-05 15:14:41 -08:00
Navl 12f0949f26 Adjusted carrier CAPI trigger events 2025-12-04 20:48:32 -08:00
David Sangrey 2041b3d3d3 [Minor] Update Type Hints and Alias Usages 2025-12-01 22:04:28 -05:00
David Sangrey 6d9b200ea8 [#2535] Redo CSV Exporter 2025-12-01 21:46:47 -05:00
Inutt 42bc097e92 Pass events prior to initial LoadGame event to plugins
Done by temporarily buffering events before monitor.mode is set, then notifying plugins about them before sending the
first event where monitor.mode has a value. LoadGame is currently the only event that sets monitor.mode.

Fixes #2286
diff --git a/EDMarketConnector.py b/EDMarketConnector.py
index e7bdf490..d53b625d 100644
--- a/EDMarketConnector.py
+++ b/EDMarketConnector.py
@@ -22,7 +22,7 @@ import threading
 import webbrowser
 from os import chdir, environ
 from time import localtime, strftime, time
-from typing import TYPE_CHECKING, Any, Literal
+from typing import TYPE_CHECKING, Any, Literal, MutableMapping
 from constants import applongname, appname, protocolhandler_redirect

 # Have this as early as possible for people running EDMarketConnector.exe
@@ -458,6 +458,8 @@ class AppWindow:

     def __init__(self, master: tk.Tk):  # noqa: C901, CCR001 # TODO - can possibly factor something out

+        self.early_journal_events: list[MutableMapping[str, Any]] = []
+
         self.capi_query_holdoff_time = config.get_int('querytime', default=0) + companion.capi_query_cooldown
         self.capi_fleetcarrier_query_holdoff_time = config.get_int('fleetcarrierquerytime', default=0) \
             + companion.capi_fleetcarrier_query_cooldown
@@ -1400,6 +1402,19 @@ class AppWindow:
         self.cooldown()
         logger.trace_if('capi.worker', '...done')

+    def handle_plugin_event_error(self, err: str | None) -> None:
+        """
+        Display a plugin's error message at the bottom of the main window.
+
+        If there was no error message passed in, nothing will be done.
+
+        :param err: Message to display, or None for no error.
+        """
+        if err:
+            self.status['text'] = err
+            if not config.get_int('hotkey_mute'):
+                hotkeymgr.play_bad()
+
     def journal_event(self, event: str):  # noqa: C901, CCR001 # Currently not easily broken up.
         """
         Handle a Journal event passed through event queue from monitor.py.
@@ -1513,15 +1528,21 @@ class AppWindow:

             if monitor.cmdr and monitor.mode == 'CQC' and entry['event']:
                 err = plug.notify_journal_entry_cqc(monitor.cmdr, monitor.is_beta, entry, monitor.state)
-                if err:
-                    self.status['text'] = err
-                    if not config.get_int('hotkey_mute'):
-                        hotkeymgr.play_bad()
+                self.handle_plugin_event_error(err)

                 return  # in CQC

             if not entry['event'] or not monitor.mode:
+                # Game session has not fully loaded yet. We may be receiving events from the
+                # journal, but don't know which game mode (Open/CQC/solo etc) we're running in.
                 logger.trace_if('journal.queue', 'Startup, returning')
+
+                if entry['event']:
+                    # Since we don't know which mode the game is in (and therefore whether to send
+                    # the event to a plugin's `journal_event` or `journal_event_cqc` function),
+                    # temporarily queue it so we can pass it on once the mode is known.
+                    self.early_journal_events.append(entry)
+
                 return  # Startup

             if entry['event'] in ('StartUp', 'LoadGame') and monitor.started:
@@ -1538,6 +1559,25 @@ class AppWindow:
                 if not dashboard.start(self.w, monitor.started):
                     logger.info("Can't start Status monitoring")

+            # monitor.cmdr should always be set if monitor.mode is set (and monitor.mode must be set
+            # if we reach this point in the function), but we check monitor.cmdr here so the mypy
+            # doesn't complain about passing str|None where str is required.
+            if self.early_journal_events and monitor.cmdr:
+                for early_entry in self.early_journal_events:
+                    if monitor.mode == 'CQC':
+                        err = plug.notify_journal_entry_cqc(monitor.cmdr, monitor.is_beta, early_entry, monitor.state)
+                    else:
+                        err = plug.notify_journal_entry(
+                            monitor.cmdr,
+                            monitor.is_beta,
+                            monitor.state['SystemName'],
+                            monitor.state['StationName'],
+                            early_entry,
+                            monitor.state
+                        )
+                    self.handle_plugin_event_error(err)
+                self.early_journal_events.clear()
+
             # Export loadout
             if entry['event'] == 'Loadout' and not monitor.state['Captain'] \
                     and config.get_int('output') & config.OUT_SHIP:
@@ -1553,10 +1593,7 @@ class AppWindow:
                     monitor.state
                 )

-                if err:
-                    self.status['text'] = err
-                    if not config.get_int('hotkey_mute'):
-                        hotkeymgr.play_bad()
+                self.handle_plugin_event_error(err)

             auto_update = False
             # Only if auth callback is not pending
@@ -1638,11 +1675,7 @@ class AppWindow:
         # Currently we don't do anything with these events
         if monitor.cmdr:
             err = plug.notify_dashboard_entry(monitor.cmdr, monitor.is_beta, entry)
-
-            if err:
-                self.status['text'] = err
-                if not config.get_int('hotkey_mute'):
-                    hotkeymgr.play_bad()
+            self.handle_plugin_event_error(err)

     def plugin_error(self, event=None) -> None:
         """Display asynchronous error from plugin."""
2025-11-28 03:37:14 +00:00
David Sangrey 8dbd5cae69 [Minor] Add Custom Config Path, Add Additional Logging 2025-11-19 20:57:41 -05:00
David Sangrey 61e8ff0c7a [Minor] Fix "Reset Provider" popup on first run 2025-11-18 18:56:37 -05:00
David Sangrey d545a78b1f Merge branch 'beta' into enhancement/261/disable-plugins 2025-11-17 20:55:49 -05:00
Ben Peddell f80ac51fe2 [Bugfix] Fix race starting journal monitor
Fixes a race identified where long plugin init times can result in
the following error being thrown in the journal monitor thread,
requiring a preferences reload to have journals continuing to be
processed:

```
Exception in thread Journal worker:
Traceback (most recent call last):
  File "/home/testing/.pyenv/versions/3.11.9/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/home/testing/.pyenv/versions/3.11.9/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/home/testing/gitstuff/EDMarketConnector/monitor.py", line 461, in worker
    self.root.event_generate('<<JournalEvent>>', when="tail")
  File "/home/testing/.pyenv/versions/3.11.9/lib/python3.11/tkinter/__init__.py", line 1933, in event_generate
    self.tk.call(args)
RuntimeError: main thread is not in main loop
```
2025-11-17 19:34:05 -05:00
David Sangrey b638326a25 Merge branch 'develop' into enhancement/517/config-unification 2025-11-16 21:50:45 -05:00
David Sangrey bbfdb0953c Merge pull request #2499 from klightspeed/fix-journal-startup-race
[Bugfix] Fix race starting journal monitor
2025-11-16 21:41:45 -05:00
David Sangrey a6bafe58b7 Remove Deprecated Functions 2025-11-13 21:45:06 -05:00
David Sangrey 03cbe85535 [2116] A Few More Hand-Overs 2025-11-11 23:17:02 -05:00
David Sangrey 119d09f187 [#1256] Add Skip-JournalLock Argument 2025-11-11 19:12:02 -05:00
David Sangrey ec67b434d3 [Minor] Reduce Privilege Request for Checking Same User 2025-11-09 15:25:51 -05:00
David Sangrey 34e73dcfb2 Updated Linter Suppression for Existing 2025-10-16 16:34:16 -04:00
Ben Peddell 4e2e3d8f61 [Bugfix] Fix race starting journal monitor
Fixes a race identified where long plugin init times can result in
the following error being thrown in the journal monitor thread,
requiring a preferences reload to have journals continuing to be
processed:

```
Exception in thread Journal worker:
Traceback (most recent call last):
  File "/home/testing/.pyenv/versions/3.11.9/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/home/testing/.pyenv/versions/3.11.9/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/home/testing/gitstuff/EDMarketConnector/monitor.py", line 461, in worker
    self.root.event_generate('<<JournalEvent>>', when="tail")
  File "/home/testing/.pyenv/versions/3.11.9/lib/python3.11/tkinter/__init__.py", line 1933, in event_generate
    self.tk.call(args)
RuntimeError: main thread is not in main loop
```
2025-10-04 01:50:31 +10:00
Navl 30a98e0da8 Modified events for fleetcarrier query 2025-08-26 21:39:07 -07:00
David Sangrey e8497c22e6 [1805] Replace Unicode Buffer 2025-04-27 13:09:23 -04:00
David Sangrey 4427ae6f25 [#1805] More Handover of Ctypes 2025-04-26 16:06:01 -04:00
David Sangrey e9c4ca6b9d [1346] Only Shutdown When Present 2025-04-26 11:04:04 -04:00
David Sangrey eae0417797 [#1346] Option to Disable Systray 2025-04-22 22:48:31 -04:00
David Sangrey ed964b3e55 Merge pull request #2408 from HullSeals/enhancement/2406/common-core-refactor
[#2406] Duplicate Code Refactor
2025-04-22 19:10:18 -04:00