[supervision] edit more reliable (#3654)
Doxygen / build (push) Waiting to run

This commit is contained in:
Fabien-B
2026-05-08 18:09:59 +02:00
committed by GitHub
parent c2fcb110b5
commit a2d680a158
2 changed files with 12 additions and 5 deletions
+6 -2
View File
@@ -7,7 +7,7 @@ from program_widget import ProgramWidget, TabProgramsState
from conf import *
from programs_conf import Tool
import subprocess
import os
class ConfigurationPanel(QWidget, Ui_ConfigurationPanel):
@@ -75,9 +75,13 @@ class ConfigurationPanel(QWidget, Ui_ConfigurationPanel):
def edit_flightplan_gcs(self, path):
if self.flight_plan_editor is not None:
cmd = [os.path.join(utils.PAPARAZZI_SRC, self.flight_plan_editor.command)]
if self.flight_plan_editor.command.startswith("$"):
cmd = [self.flight_plan_editor.command[1:]]
else:
cmd = [os.path.join(utils.PAPARAZZI_SRC, self.flight_plan_editor.command)]
for arg in self.flight_plan_editor.args:
cmd += arg.args()
cmd.append(os.path.join(utils.CONF_DIR, path))
subprocess.Popen(cmd)
# self.launch_program(self.flight_plan_editor.name, cmd, self.flight_plan_editor.icon)
+6 -3
View File
@@ -6,7 +6,9 @@ from PyQt5.QtWidgets import *
from typing import NamedTuple
from PyQt5.QtCore import QSettings
import subprocess
from shutil import which
EDITORS = ["gnome-text-editor", "kate"]
class GConfEntry(NamedTuple):
name: str
@@ -36,9 +38,10 @@ def remove_suffix(s: str, suffix: str, /) -> str:
# TODO: make it work with shell program such as vim.
def edit_file(file_path, prefix=CONF_DIR):
path = prefix + file_path
editor = get_settings().value("text_editor", "", str)
if editor == "":
editor = "gedit"
editor = ""
for editor in [get_settings().value("text_editor", "", str), *EDITORS]:
if which(editor) is not None:
break
try:
subprocess.Popen([editor, path])
except Exception as e: