Feat: Update settings tab implemented.
Auto-updates now configurable (URL, source (gitea or private server), log activity for auto updates. fix: Update now hardened to prevent installation of corrupt or incorrect .exe files. (security to be hardened in the future)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Series 3 Watcher — Settings Dialog v1.4.2
|
||||
Series 3 Watcher — Settings Dialog v1.4.3
|
||||
|
||||
Provides a Tkinter settings dialog that doubles as a first-run wizard.
|
||||
|
||||
@@ -39,6 +39,10 @@ DEFAULTS = {
|
||||
"Series3Watcher", "agent_logs", "series3_watcher.log"
|
||||
),
|
||||
"LOG_RETENTION_DAYS": "30",
|
||||
|
||||
# Auto-updater
|
||||
"UPDATE_SOURCE": "gitea",
|
||||
"UPDATE_URL": "",
|
||||
}
|
||||
|
||||
|
||||
@@ -233,6 +237,10 @@ class SettingsDialog:
|
||||
self.var_enable_logging = tk.BooleanVar(value=v["ENABLE_LOGGING"].lower() in ("1","true","yes","on"))
|
||||
self.var_log_retention_days = tk.StringVar(value=v["LOG_RETENTION_DAYS"])
|
||||
|
||||
# Updates
|
||||
self.var_update_source = tk.StringVar(value=v["UPDATE_SOURCE"].lower() if v["UPDATE_SOURCE"].lower() in ("gitea", "url", "disabled") else "gitea")
|
||||
self.var_update_url = tk.StringVar(value=v["UPDATE_URL"])
|
||||
|
||||
# --- UI construction ---
|
||||
|
||||
def _build_ui(self):
|
||||
@@ -259,6 +267,7 @@ class SettingsDialog:
|
||||
self._build_tab_paths(nb)
|
||||
self._build_tab_scanning(nb)
|
||||
self._build_tab_logging(nb)
|
||||
self._build_tab_updates(nb)
|
||||
|
||||
# Buttons
|
||||
btn_frame = tk.Frame(outer)
|
||||
@@ -398,6 +407,68 @@ class SettingsDialog:
|
||||
_add_label_check(f, 0, "Enable Logging", self.var_enable_logging)
|
||||
_add_label_spinbox(f, 1, "Log Retention (days)", self.var_log_retention_days, 1, 365)
|
||||
|
||||
def _build_tab_updates(self, nb):
|
||||
f = self._tab_frame(nb, "Updates")
|
||||
|
||||
tk.Label(
|
||||
f,
|
||||
text="Auto-Update Source",
|
||||
anchor="w",
|
||||
).grid(row=0, column=0, sticky="w", padx=(8, 4), pady=(8, 2))
|
||||
|
||||
radio_frame = tk.Frame(f)
|
||||
radio_frame.grid(row=0, column=1, sticky="w", padx=(0, 8), pady=(8, 2))
|
||||
|
||||
rb_gitea = ttk.Radiobutton(
|
||||
radio_frame, text="Gitea (default)",
|
||||
variable=self.var_update_source, value="gitea",
|
||||
command=self._on_update_source_change,
|
||||
)
|
||||
rb_gitea.grid(row=0, column=0, sticky="w", padx=(0, 12))
|
||||
|
||||
rb_url = ttk.Radiobutton(
|
||||
radio_frame, text="Custom URL",
|
||||
variable=self.var_update_source, value="url",
|
||||
command=self._on_update_source_change,
|
||||
)
|
||||
rb_url.grid(row=0, column=1, sticky="w", padx=(0, 12))
|
||||
|
||||
rb_disabled = ttk.Radiobutton(
|
||||
radio_frame, text="Disabled",
|
||||
variable=self.var_update_source, value="disabled",
|
||||
command=self._on_update_source_change,
|
||||
)
|
||||
rb_disabled.grid(row=0, column=2, sticky="w")
|
||||
|
||||
tk.Label(f, text="Update Server URL", anchor="w").grid(
|
||||
row=1, column=0, sticky="w", padx=(8, 4), pady=4
|
||||
)
|
||||
self._update_url_entry = ttk.Entry(f, textvariable=self.var_update_url, width=42)
|
||||
self._update_url_entry.grid(row=1, column=1, sticky="ew", padx=(0, 8), pady=4)
|
||||
|
||||
hint_text = (
|
||||
"Gitea: checks the Gitea release page automatically every 5 minutes.\n"
|
||||
"Custom URL: fetches version.txt and series3-watcher.exe from a web\n"
|
||||
"server — use when Gitea is not reachable (e.g. terra-view URL).\n"
|
||||
"Disabled: no automatic update checks. Remote push from terra-view\n"
|
||||
"still works when disabled."
|
||||
)
|
||||
tk.Label(f, text=hint_text, justify="left", fg="#555555",
|
||||
wraplength=380).grid(
|
||||
row=2, column=0, columnspan=2, sticky="w", padx=(8, 8), pady=(4, 8)
|
||||
)
|
||||
|
||||
# Set initial state of URL entry
|
||||
self._on_update_source_change()
|
||||
|
||||
def _on_update_source_change(self):
|
||||
"""Enable/disable the URL entry based on selected update source."""
|
||||
if self.var_update_source.get() == "url":
|
||||
self._update_url_entry.config(state="normal")
|
||||
else:
|
||||
self._update_url_entry.config(state="disabled")
|
||||
|
||||
|
||||
# --- Validation helpers ---
|
||||
|
||||
def _get_int_var(self, var, name, min_val, max_val, default):
|
||||
@@ -467,6 +538,8 @@ class SettingsDialog:
|
||||
"ENABLE_LOGGING": "true" if self.var_enable_logging.get() else "false",
|
||||
"LOG_FILE": self.var_log_file.get().strip(),
|
||||
"LOG_RETENTION_DAYS": str(int_values["Log Retention Days"]),
|
||||
"UPDATE_SOURCE": self.var_update_source.get().strip() or "gitea",
|
||||
"UPDATE_URL": self.var_update_url.get().strip(),
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user