src/eric7/Project/DebuggerPropertiesFile.py

branch
server
changeset 10596
ea35c92a3c7c
parent 10459
5c5ed40d533d
child 11090
f5f5f5803935
diff -r 6156d9675f62 -r ea35c92a3c7c src/eric7/Project/DebuggerPropertiesFile.py
--- a/src/eric7/Project/DebuggerPropertiesFile.py	Mon Feb 19 19:37:00 2024 +0100
+++ b/src/eric7/Project/DebuggerPropertiesFile.py	Thu Feb 22 16:26:46 2024 +0100
@@ -17,6 +17,8 @@
 from eric7 import Preferences
 from eric7.EricGui.EricOverrideCursor import EricOverridenCursor
 from eric7.EricWidgets import EricMessageBox
+from eric7.EricWidgets.EricApplication import ericApp
+from eric7.SystemUtilities import FileSystemUtilities
 
 Project = typing.TypeVar("Project")
 
@@ -48,6 +50,10 @@
         @return flag indicating a successful write
         @rtype bool
         """
+        fsInterface = (
+            ericApp().getObject("EricServer").getServiceInterface("FileSystem")
+        )
+
         debuggerPropertiesDict = {
             "header": {
                 "comment": "eric debugger properties file for project {0}".format(
@@ -66,13 +72,18 @@
 
         try:
             jsonString = json.dumps(debuggerPropertiesDict, indent=2) + "\n"
-            with open(filename, "w") as f:
-                f.write(jsonString)
+            if FileSystemUtilities.isRemoteFileName(filename):
+                title = self.tr("Save Remote Debugger Properties")
+                fsInterface.writeFile(filename, jsonString.encode("utf-8"))
+            else:
+                title = self.tr("Save Debugger Properties")
+                with open(filename, "w") as f:
+                    f.write(jsonString)
         except (OSError, TypeError) as err:
             with EricOverridenCursor():
                 EricMessageBox.critical(
                     None,
-                    self.tr("Save Debugger Properties"),
+                    title,
                     self.tr(
                         "<p>The project debugger properties file"
                         " <b>{0}</b> could not be written.</p>"
@@ -93,14 +104,23 @@
         @return flag indicating a successful read
         @rtype bool
         """
+        fsInterface = (
+            ericApp().getObject("EricServer").getServiceInterface("FileSystem")
+        )
+
         try:
-            with open(filename, "r") as f:
-                jsonString = f.read()
+            if FileSystemUtilities.isRemoteFileName(filename):
+                title = self.tr("Read Remote Debugger Properties")
+                jsonString = fsInterface.readFile(filename).decode("utf-8")
+            else:
+                title = self.tr("Read Debugger Properties")
+                with open(filename, "r") as f:
+                    jsonString = f.read()
             debuggerPropertiesDict = json.loads(jsonString)
         except (OSError, json.JSONDecodeError) as err:
             EricMessageBox.critical(
                 None,
-                self.tr("Read Debugger Properties"),
+                title,
                 self.tr(
                     "<p>The project debugger properties file <b>{0}</b>"
                     " could not be read.</p><p>Reason: {1}</p>"

eric ide

mercurial