mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2026-11-22 03:06:59 +03:00
Merge branch 'stable' into releases
This commit is contained in:
5 files changed
+144
-72
No files matched your search
@@ -2,6 +2,20 @@ This is the master changelog for Elite Dangerous Market Connector. Entries are
|
||||
---
|
||||
* We currently test against, and package with, Python 3.13, 64-bit.
|
||||
---
|
||||
Release 6.1.1
|
||||
===
|
||||
This release contains a handful of bugfixes for 6.1, including updates for the new Config system.
|
||||
|
||||
**Changes and Enhancements**
|
||||
* Added a backup and autorecovery system for the Config file.
|
||||
* Improved the stability of the Config system management.
|
||||
* Updated Italian translations.
|
||||
|
||||
**Bug Fixes**
|
||||
* Fixed a bug where datafiles and FDEV ID files would not be updated on program start.
|
||||
* Fixed a series of bugs where the Config system could be corrupted on data interruption (such as a power loss).
|
||||
* Fixed a bug where the Plugin Browser could display rows too thin, causing title clipping.
|
||||
|
||||
Release 6.1.0
|
||||
===
|
||||
This release includes the new EDMC Plugin Browser, which allows plugin authors to register their plugins.
|
||||
|
||||
@@ -67,6 +67,7 @@ from config import appversion, appversion_nobuild, config, copyright
|
||||
|
||||
from EDMCLogging import edmclogger, logger, logging
|
||||
from journal_lock import JournalLock, JournalLockResult
|
||||
from update import check_for_datafile_updates, check_for_fdev_updates
|
||||
from common_utils import log_locale, SERVER_RETRY
|
||||
|
||||
if __name__ == '__main__': # noqa: C901
|
||||
@@ -2460,6 +2461,8 @@ sys.path: {sys.path}'''
|
||||
root.after(2, show_killswitch_poppup, root)
|
||||
# Start the main event loop
|
||||
try:
|
||||
check_for_datafile_updates()
|
||||
check_for_fdev_updates()
|
||||
root.mainloop()
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Ctrl+C Detected, Attempting Clean Shutdown")
|
||||
|
||||
+22
-22
@@ -496,13 +496,13 @@
|
||||
"Error in System Profiler" = "Errore nel Sistema di Profilazione";
|
||||
|
||||
/* prefs.py: Disabling a Plugin. */
|
||||
"Disabling plugin {PLUGIN}. This will cause a restart. Click OK to continue..." = "Disabling plugin {PLUGIN}. This will cause a restart. Click OK to continue...";
|
||||
"Disabling plugin {PLUGIN}. This will cause a restart. Click OK to continue..." = "Disabilitare il plugin {PLUGIN}. Questo causerà il riavvio. Fai clic su OK per continuare...";
|
||||
|
||||
/* prefs.py: Enable a Disabled Plugin */
|
||||
"Enable" = "Enable";
|
||||
"Enable" = "Attiva";
|
||||
|
||||
/* prefs.py: Disable an Enabled Plugin */
|
||||
"Disable" = "Disable";
|
||||
"Disable" = "Disattiva";
|
||||
|
||||
/* stats.py: Cmdr stats; In files: stats.py:58; */
|
||||
"Balance" = "Saldo";
|
||||
@@ -835,61 +835,61 @@
|
||||
"Copy Inara SLEF" = "Copia Inara SLEF";
|
||||
|
||||
/* edastro_core.py: Settings>EDAstro - Label on checkbox for 'send data'; */
|
||||
"Send data to EDAstro" = "Send data to EDAstro";
|
||||
"Send data to EDAstro" = "Invia dati a EDAstro";
|
||||
|
||||
/* common_coreutils.py: Colonisation ship name, with title; In files: common_coreutils.py:81:81 */
|
||||
"System Colonisation Ship {NAME}" = "System Colonisation Ship {NAME}";
|
||||
"System Colonisation Ship {NAME}" = "Nave di Colonizzazione del Sistema {NAME}";
|
||||
|
||||
/* common_coreutils.py: Unidentified colonisation ship; In files: common_coreutils.py:84:84 */
|
||||
"System Colonisation Ship" = "System Colonisation Ship";
|
||||
"System Colonisation Ship" = "Nave di colonizzazione del Sistema";
|
||||
|
||||
/* plugin_browser.py: Filter Plugin Categories */
|
||||
"Filter by Category:" = "Filter by Category:";
|
||||
"Filter by Category:" = "Filtra per Categoria:";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Plug Name */
|
||||
"Name" = "Name";
|
||||
"Name" = "Nome";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Plug Ver */
|
||||
"Version" = "Version";
|
||||
"Version" = "Versione";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Last Update */
|
||||
"Last Updated" = "Last Updated";
|
||||
"Last Updated" = "Ultimo aggiornamento";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Category */
|
||||
"Categories" = "Categories";
|
||||
"Categories" = "Categorie";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Description */
|
||||
"Description" = "Description";
|
||||
"Description" = "Descrizione";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Stars */
|
||||
"Stars" = "Stars";
|
||||
"Stars" = "Stelle";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Title */
|
||||
"Plugin Browser" = "Plugin Browser";
|
||||
"Plugin Browser" = "Browser Plugin";
|
||||
|
||||
/* plugin_browser.py: Open Plugin Repo */
|
||||
"Open Plugin Repository" = "Open Plugin Repository";
|
||||
"Open Plugin Repository" = "Apri Repository Plugin";
|
||||
|
||||
/* plugin_browser.py: Report a Malfunctioning Plugin */
|
||||
"Report Plugin" = "Report Plugin";
|
||||
"Report Plugin" = "Plugin Report";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Authors */
|
||||
"Authors" = "Authors";
|
||||
"Authors" = "Autori";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser License */
|
||||
"License" = "License";
|
||||
"License" = "Licenza";
|
||||
|
||||
/* plugin_browser.py: Plugin Browser Reqs */
|
||||
"Requirements" = "Requirements";
|
||||
"Requirements" = "Requisiti";
|
||||
|
||||
/* plugin_browser.py: Last Tested EDMC Version */
|
||||
"Last Tested EDMC: {last_tested}" = "Last Tested EDMC: {last_tested}";
|
||||
"Last Tested EDMC: {last_tested}" = "Ultimo EDMC testato: {last_tested}";
|
||||
|
||||
/* plugin_browser.py: Plugin Project Link */
|
||||
"Main Project Link" = "Main Project Link";
|
||||
"Main Project Link" = "Link del Progetto Principale";
|
||||
|
||||
/* plugin_browser.py: Plugin VT Link */
|
||||
"VirusTotal Link" = "VirusTotal Link";
|
||||
|
||||
/* prefs.py: Settings > Output - choose delimiter/format for market export files */
|
||||
"Market export format:" = "Market export format:";
|
||||
"Market export format:" = "Formato esportazione mercato:";
|
||||
+103
-49
@@ -42,8 +42,8 @@ import subprocess
|
||||
import sys
|
||||
import tomllib
|
||||
import tomli_w
|
||||
import time
|
||||
from typing import Any, TypeVar
|
||||
from collections.abc import Callable
|
||||
from collections import defaultdict
|
||||
import semantic_version
|
||||
from constants import GITVERSION_FILE, applongname, appname
|
||||
@@ -54,9 +54,9 @@ appcmdname = "EDMC"
|
||||
# <https://semver.org/#semantic-versioning-specification-semver>
|
||||
# Major.Minor.Patch(-prerelease)(+buildmetadata)
|
||||
# NB: Do *not* import this, use the functions appversion() and appversion_nobuild()
|
||||
_static_appversion = "6.1.0"
|
||||
_static_appversion = "6.1.1"
|
||||
_cached_version: semantic_version.Version | None = None
|
||||
copyright = "© 2015-2019 Jonathan Harris, 2020-2025 EDCD"
|
||||
copyright = "© 2015-2019 Jonathan Harris, 2020-2026 EDCD"
|
||||
|
||||
|
||||
update_interval = 8 * 60 * 60 # 8 Hours
|
||||
@@ -219,11 +219,13 @@ class Config:
|
||||
self._load()
|
||||
self.default_plugin_dir_path = self.app_dir_path / "plugins"
|
||||
plugdir_str = self.get_str("plugin_dir")
|
||||
if not self.get_str("plugin_dir"):
|
||||
plugdir_str = str(self.default_plugin_dir)
|
||||
|
||||
if not plugdir_str:
|
||||
plugdir_str = str(self.default_plugin_dir_path)
|
||||
self.plugin_dir_path = self.default_plugin_dir_path
|
||||
self.set("plugin_dir", plugdir_str)
|
||||
if plugdir_str is None or not pathlib.Path(plugdir_str).is_dir():
|
||||
|
||||
if not pathlib.Path(plugdir_str).is_dir():
|
||||
self.set("plugin_dir", str(self.default_plugin_dir_path))
|
||||
plugdir_str = self.default_plugin_dir
|
||||
self.plugin_dir_path = pathlib.Path(self.get('plugin_dir'))
|
||||
@@ -248,32 +250,107 @@ class Config:
|
||||
"""Set flag denoting we're in the shutdown sequence."""
|
||||
self.__in_shutdown = True
|
||||
|
||||
def _default_data(self) -> dict:
|
||||
return {
|
||||
"generated": "",
|
||||
"source": "",
|
||||
"settings": {},
|
||||
}
|
||||
|
||||
def _validate_data(self, data: dict) -> dict:
|
||||
if not isinstance(data, dict):
|
||||
raise ValueError("Config root is not a table")
|
||||
|
||||
settings = data.get("settings", {})
|
||||
if not isinstance(settings, dict):
|
||||
raise ValueError("Config 'settings' is not a table")
|
||||
|
||||
return {
|
||||
"generated": data.get("generated", ""),
|
||||
"source": data.get("source", ""),
|
||||
"settings": dict(settings),
|
||||
}
|
||||
|
||||
def _load(self):
|
||||
"""Load TOML from disk and store fields. Create file if missing."""
|
||||
self.toml_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if not self.toml_path.exists():
|
||||
# Ensure parent directories exist
|
||||
self.toml_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
data = self._default_data()
|
||||
self._write_atomic(data)
|
||||
self._apply_loaded(data)
|
||||
return
|
||||
|
||||
# Replace None with TOML-serializable defaults
|
||||
default_data = {
|
||||
"generated": "", # empty string instead of None
|
||||
"source": "", # empty string instead of None
|
||||
"settings": {} # empty table
|
||||
}
|
||||
with self.toml_path.open("wb") as f:
|
||||
tomli_w.dump(default_data, f)
|
||||
try:
|
||||
with self.toml_path.open("rb") as f:
|
||||
data = tomllib.load(f)
|
||||
data = self._validate_data(data)
|
||||
self._apply_loaded(data)
|
||||
return
|
||||
|
||||
# Load the TOML file
|
||||
with self.toml_path.open("rb") as f:
|
||||
data = tomllib.load(f)
|
||||
except (tomllib.TOMLDecodeError, OSError, ValueError) as e:
|
||||
logger.error(f"Config load failed, attempting recovery: {e!r}")
|
||||
|
||||
# Capture metadata, fallback to empty string if missing
|
||||
# Attempt Recovery
|
||||
|
||||
broken = self.toml_path.with_suffix(f".toml.broken.{int(time.time())}")
|
||||
with contextlib.suppress(Exception):
|
||||
self.toml_path.replace(broken)
|
||||
|
||||
# Try backup
|
||||
bak = self.toml_path.with_suffix(".toml.bak")
|
||||
if bak.exists():
|
||||
try:
|
||||
with bak.open("rb") as f:
|
||||
data = tomllib.load(f)
|
||||
data = self._validate_data(data)
|
||||
|
||||
# Restore backup as main
|
||||
bak.replace(self.toml_path)
|
||||
self._apply_loaded(data)
|
||||
logger.warning("Recovered config from backup.")
|
||||
return
|
||||
except Exception as e:
|
||||
logger.error(f"Backup recovery failed: {e!r}")
|
||||
|
||||
# Fallback: regenerate defaults
|
||||
logger.error("All config recovery failed, regenerating defaults.")
|
||||
data = self._default_data()
|
||||
self._write_atomic(data)
|
||||
self._apply_loaded(data)
|
||||
|
||||
def _apply_loaded(self, data: dict):
|
||||
self.generated = data.get("generated", "")
|
||||
self.source = data.get("source", "")
|
||||
|
||||
# Settings dict created by write_registry_to_toml()
|
||||
self.settings = dict(data.get("settings", {}))
|
||||
|
||||
def _write_atomic(self, data: dict):
|
||||
tmp = self.toml_path.with_suffix(".toml.tmp")
|
||||
bak = self.toml_path.with_suffix(".toml.bak")
|
||||
|
||||
with tmp.open("wb") as f:
|
||||
tomli_w.dump(data, f)
|
||||
f.flush()
|
||||
os.fsync(f.fileno())
|
||||
|
||||
# Rotate backup
|
||||
if self.toml_path.exists():
|
||||
with contextlib.suppress(Exception):
|
||||
self.toml_path.replace(bak)
|
||||
|
||||
tmp.replace(self.toml_path)
|
||||
|
||||
# Best-effort directory fsync
|
||||
with contextlib.suppress(Exception):
|
||||
try:
|
||||
# POSIX: Open as Directory
|
||||
with self.toml_path.parent.open("rb") as d:
|
||||
os.fsync(d.fileno())
|
||||
except (IsADirectoryError, PermissionError, OSError):
|
||||
pass
|
||||
|
||||
def get(self, key: str, default=None):
|
||||
"""Return raw stored value."""
|
||||
return self.settings.get(key.lower(), default)
|
||||
@@ -321,9 +398,7 @@ class Config:
|
||||
def get_list(self, key: str, default=None):
|
||||
"""Return the list referred to by the given key if it exists, or the default."""
|
||||
val = self.get(key.lower())
|
||||
return (
|
||||
val if isinstance(val, list) else (default if default is not None else [])
|
||||
)
|
||||
return val if isinstance(val, list) else (default if default is not None else [])
|
||||
|
||||
@property
|
||||
def shutting_down(self) -> bool:
|
||||
@@ -462,7 +537,7 @@ class Config:
|
||||
# Re-run plugin_dir logic
|
||||
plugdir_str = self.get_str("plugin_dir")
|
||||
if not plugdir_str:
|
||||
plugdir_str = str(self.default_plugin_dir)
|
||||
plugdir_str = str(self.default_plugin_dir_path)
|
||||
self.plugin_dir_path = self.default_plugin_dir_path
|
||||
self.set("plugin_dir", plugdir_str)
|
||||
elif not pathlib.Path(plugdir_str).is_dir():
|
||||
@@ -472,32 +547,13 @@ class Config:
|
||||
self.plugin_dir_path = pathlib.Path(plugdir_str)
|
||||
self.plugin_dir_path.mkdir(exist_ok=True)
|
||||
|
||||
@staticmethod
|
||||
def _suppress_call(
|
||||
func: Callable[..., _T],
|
||||
exceptions: type[BaseException] | list[type[BaseException]] = Exception,
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
) -> _T | None:
|
||||
if exceptions is None:
|
||||
exceptions = [Exception]
|
||||
|
||||
if not isinstance(exceptions, list):
|
||||
exceptions = [exceptions]
|
||||
|
||||
with contextlib.suppress(*exceptions):
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return None
|
||||
|
||||
def delete(self, key: str, *, suppress=False) -> None:
|
||||
"""Delete the given key from the config."""
|
||||
try:
|
||||
self.settings.pop(key.lower(), None)
|
||||
except (KeyError, IndexError):
|
||||
if suppress:
|
||||
return
|
||||
raise
|
||||
except Exception:
|
||||
if not suppress:
|
||||
raise
|
||||
self.save()
|
||||
|
||||
def set(self, key: str, value: Any):
|
||||
@@ -515,9 +571,7 @@ class Config:
|
||||
"source": self.source,
|
||||
"settings": self.settings,
|
||||
}
|
||||
|
||||
with self.toml_path.open("wb") as f:
|
||||
tomli_w.dump(data, f)
|
||||
self._write_atomic(data)
|
||||
|
||||
def close(self) -> None:
|
||||
"""Save config changes before closing."""
|
||||
|
||||
+2
-1
@@ -159,6 +159,7 @@ class PluginBrowserMixIn:
|
||||
tree_container = nb.Frame(plugins_frame) # type: ignore
|
||||
tree_row = next(row)
|
||||
tree_container.grid(row=tree_row, column=0, sticky=tk.NSEW, padx=self.PADX)
|
||||
plugins_frame.rowconfigure(tree_row, weight=1)
|
||||
|
||||
plugins_frame.columnconfigure(0, weight=1)
|
||||
|
||||
@@ -214,7 +215,7 @@ class PluginBrowserMixIn:
|
||||
scrollbar.grid(row=0, column=1, sticky=tk.NS)
|
||||
|
||||
tree_container.columnconfigure(0, weight=1)
|
||||
tree_container.rowconfigure(0, weight=0)
|
||||
tree_container.rowconfigure(0, weight=1)
|
||||
|
||||
ttk.Separator(plugins_frame, orient=tk.HORIZONTAL).grid(
|
||||
columnspan=4, padx=self.PADX, pady=self.SEPY, sticky=tk.EW, row=next(row)
|
||||
|
||||
Reference in new issue
Block a user