better faulty encoding detection
This commit is contained in:
1 parent
ec8e79bb1a
commit
2a4c5f4f7c
12 files changed
+299
-25
No files matched your search
@@ -4,12 +4,13 @@ import subprocess
|
||||
import threading
|
||||
from tkinter import ttk, messagebox
|
||||
|
||||
SERVICE = "syncthing@sebastien.service"
|
||||
SERVICE = "syncthing.service"
|
||||
SYSTEMCTL = ("systemctl", "--user", "--no-ask-password")
|
||||
|
||||
|
||||
def service_status():
|
||||
result = subprocess.run(
|
||||
["systemctl", "show", SERVICE, "--property=ActiveState", "--value"],
|
||||
[*SYSTEMCTL, "show", SERVICE, "--property=ActiveState", "--value"],
|
||||
capture_output=True, text=True, timeout=10,
|
||||
)
|
||||
if result.returncode:
|
||||
@@ -22,7 +23,7 @@ def control_service(action):
|
||||
return "active"
|
||||
command = "start" if action == "ensure" else action
|
||||
result = subprocess.run(
|
||||
["systemctl", "--no-ask-password", command, SERVICE],
|
||||
[*SYSTEMCTL, command, SERVICE],
|
||||
capture_output=True, text=True, timeout=60,
|
||||
)
|
||||
if result.returncode:
|
||||
@@ -87,13 +88,18 @@ class SyncthingPanel(ttk.Frame):
|
||||
self.start_button.configure(state="normal")
|
||||
self.stop_button.configure(state="normal")
|
||||
self.status.configure(text=f"{SERVICE} : {error or status}")
|
||||
if error and action != "status":
|
||||
self.pending_export = None
|
||||
messagebox.showerror("Syncthing", error)
|
||||
elif action == "ensure":
|
||||
if action == "ensure":
|
||||
callback, self.pending_export = self.pending_export, None
|
||||
if error:
|
||||
messagebox.showwarning(
|
||||
"Syncthing",
|
||||
f"Impossible de démarrer Syncthing : {error}\n\n"
|
||||
"L’export va continuer.",
|
||||
)
|
||||
if callback:
|
||||
callback()
|
||||
elif error and action != "status":
|
||||
messagebox.showerror("Syncthing", error)
|
||||
elif self.pending_export:
|
||||
self.request("ensure")
|
||||
if self.winfo_exists():
|
||||
|
||||
Reference in new issue
Block a user