src/eric7/RemoteServer/EricServerFileSystemRequestHandler.py

branch
server
changeset 10767
b3672d3e7644
parent 10722
b74d46513011
child 10948
89b36a39fe69
diff -r d35d6f96c24b -r b3672d3e7644 src/eric7/RemoteServer/EricServerFileSystemRequestHandler.py
--- a/src/eric7/RemoteServer/EricServerFileSystemRequestHandler.py	Mon Jun 10 11:41:34 2024 +0200
+++ b/src/eric7/RemoteServer/EricServerFileSystemRequestHandler.py	Mon Jun 10 15:42:05 2024 +0200
@@ -17,9 +17,10 @@
 from eric7.SystemUtilities import FileSystemUtilities
 
 from .EricRequestCategory import EricRequestCategory
+from .EricServerBaseRequestHandler import EricServerBaseRequestHandler
 
 
-class EricServerFileSystemRequestHandler:
+class EricServerFileSystemRequestHandler(EricServerBaseRequestHandler):
     """
     Class implementing the file system request handler of the eric-ide server.
     """
@@ -31,9 +32,11 @@
         @param server reference to the eric-ide server object
         @type EricServer
         """
-        self.__server = server
+        super().__init__(server)
 
-        self.__requestMethodMapping = {
+        self._category = EricRequestCategory.FileSystem
+
+        self._requestMethodMapping = {
             "GetPathSep": self.__getPathSeparator,
             "Chdir": self.__chdir,
             "Getcwd": self.__getcwd,
@@ -54,37 +57,30 @@
             "ShutilRmtree": self.__shutilRmtree,
         }
 
-    def handleRequest(self, request, params, reqestUuid):
+    def sendError(self, request, reqestUuid=""):
         """
-        Public method handling the received file system requests.
+        Public method to send an error report to the IDE.
 
         @param request request name
         @type str
-        @param params dictionary containing the request parameters
-        @type dict
         @param reqestUuid UUID of the associated request as sent by the eric IDE
+            (defaults to "", i.e. no UUID received)
         @type str
         """
-        try:
-            result = self.__requestMethodMapping[request](params)
-            self.__server.sendJson(
-                category=EricRequestCategory.FileSystem,
-                reply=request,
-                params=result,
-                reqestUuid=reqestUuid,
-            )
+        self._server.sendJson(
+            category=self._category,
+            reply=request,
+            params={
+                "ok": False,
+                "error": f"Request type '{request}' is not supported.",
+                "info": list(self._requestMethodMapping.keys()),
+            },
+            reqestUuid=reqestUuid,
+        )
 
-        except KeyError:
-            self.__server.sendJson(
-                category=EricRequestCategory.FileSystem,
-                reply=request,
-                params={
-                    "ok": False,
-                    "error": f"Request type '{request}' is not supported.",
-                    "info": list(self.__requestMethodMapping.keys()),
-                },
-                reqestUuid=reqestUuid,
-            )
+    ############################################################################
+    ## File system related methods below
+    ############################################################################
 
     def __getPathSeparator(self, params):  # noqa: U100
         """

eric ide

mercurial