src/eric7/RemoteServer/EricServerFileSystemRequestHandler.py

branch
server
changeset 10767
b3672d3e7644
parent 10722
b74d46513011
child 10948
89b36a39fe69
equal deleted inserted replaced
10766:d35d6f96c24b 10767:b3672d3e7644
15 import time 15 import time
16 16
17 from eric7.SystemUtilities import FileSystemUtilities 17 from eric7.SystemUtilities import FileSystemUtilities
18 18
19 from .EricRequestCategory import EricRequestCategory 19 from .EricRequestCategory import EricRequestCategory
20 20 from .EricServerBaseRequestHandler import EricServerBaseRequestHandler
21 21
22 class EricServerFileSystemRequestHandler: 22
23 class EricServerFileSystemRequestHandler(EricServerBaseRequestHandler):
23 """ 24 """
24 Class implementing the file system request handler of the eric-ide server. 25 Class implementing the file system request handler of the eric-ide server.
25 """ 26 """
26 27
27 def __init__(self, server): 28 def __init__(self, server):
29 Constructor 30 Constructor
30 31
31 @param server reference to the eric-ide server object 32 @param server reference to the eric-ide server object
32 @type EricServer 33 @type EricServer
33 """ 34 """
34 self.__server = server 35 super().__init__(server)
35 36
36 self.__requestMethodMapping = { 37 self._category = EricRequestCategory.FileSystem
38
39 self._requestMethodMapping = {
37 "GetPathSep": self.__getPathSeparator, 40 "GetPathSep": self.__getPathSeparator,
38 "Chdir": self.__chdir, 41 "Chdir": self.__chdir,
39 "Getcwd": self.__getcwd, 42 "Getcwd": self.__getcwd,
40 "Listdir": self.__listdir, 43 "Listdir": self.__listdir,
41 "Mkdir": self.__mkdir, 44 "Mkdir": self.__mkdir,
52 "ExpandUser": self.__expanduser, 55 "ExpandUser": self.__expanduser,
53 "ShutilCopy": self.__shutilCopy, 56 "ShutilCopy": self.__shutilCopy,
54 "ShutilRmtree": self.__shutilRmtree, 57 "ShutilRmtree": self.__shutilRmtree,
55 } 58 }
56 59
57 def handleRequest(self, request, params, reqestUuid): 60 def sendError(self, request, reqestUuid=""):
58 """ 61 """
59 Public method handling the received file system requests. 62 Public method to send an error report to the IDE.
60 63
61 @param request request name 64 @param request request name
62 @type str 65 @type str
63 @param params dictionary containing the request parameters
64 @type dict
65 @param reqestUuid UUID of the associated request as sent by the eric IDE 66 @param reqestUuid UUID of the associated request as sent by the eric IDE
67 (defaults to "", i.e. no UUID received)
66 @type str 68 @type str
67 """ 69 """
68 try: 70 self._server.sendJson(
69 result = self.__requestMethodMapping[request](params) 71 category=self._category,
70 self.__server.sendJson( 72 reply=request,
71 category=EricRequestCategory.FileSystem, 73 params={
72 reply=request, 74 "ok": False,
73 params=result, 75 "error": f"Request type '{request}' is not supported.",
74 reqestUuid=reqestUuid, 76 "info": list(self._requestMethodMapping.keys()),
75 ) 77 },
76 78 reqestUuid=reqestUuid,
77 except KeyError: 79 )
78 self.__server.sendJson( 80
79 category=EricRequestCategory.FileSystem, 81 ############################################################################
80 reply=request, 82 ## File system related methods below
81 params={ 83 ############################################################################
82 "ok": False,
83 "error": f"Request type '{request}' is not supported.",
84 "info": list(self.__requestMethodMapping.keys()),
85 },
86 reqestUuid=reqestUuid,
87 )
88 84
89 def __getPathSeparator(self, params): # noqa: U100 85 def __getPathSeparator(self, params): # noqa: U100
90 """ 86 """
91 Private method to report the path separator. 87 Private method to report the path separator.
92 88

eric ide

mercurial