36 "GetPathSep": self.__getPathSeparator, |
36 "GetPathSep": self.__getPathSeparator, |
37 "Chdir": self.__chdir, |
37 "Chdir": self.__chdir, |
38 "Getcwd": self.__getcwd, |
38 "Getcwd": self.__getcwd, |
39 "Listdir": self.__listdir, |
39 "Listdir": self.__listdir, |
40 "Mkdir": self.__mkdir, |
40 "Mkdir": self.__mkdir, |
|
41 "MakeDirs": self.__makedirs, |
41 "Rmdir": self.__rmdir, |
42 "Rmdir": self.__rmdir, |
42 "Replace": self.__replace, |
43 "Replace": self.__replace, |
43 "Remove": self.__remove, |
44 "Remove": self.__remove, |
44 "Stat": self.__stat, |
45 "Stat": self.__stat, |
45 "Exists": self.__exists, |
46 "Exists": self.__exists, |
71 |
72 |
72 except KeyError: |
73 except KeyError: |
73 self.__server.sendJson( |
74 self.__server.sendJson( |
74 category=EricRequestCategory.FileSystem, |
75 category=EricRequestCategory.FileSystem, |
75 reply=request, |
76 reply=request, |
76 params={"Error": f"Request type '{request}' is not supported."}, |
77 params={ |
|
78 "ok": False, |
|
79 "error": f"Request type '{request}' is not supported.", |
|
80 "info": list(self.__requestMethodMapping.keys()), |
|
81 }, |
|
82 reqestUuid=reqestUuid, |
77 ) |
83 ) |
78 |
84 |
79 def __getPathSeparator(self, params): |
85 def __getPathSeparator(self, params): |
80 """ |
86 """ |
81 Private method to report the path separator. |
87 Private method to report the path separator. |
168 @param params dictionary containing the request data |
173 @param params dictionary containing the request data |
169 @type dict |
174 @type dict |
170 @return dictionary containing the reply data |
175 @return dictionary containing the reply data |
171 @rtype dict |
176 @rtype dict |
172 """ |
177 """ |
173 filename = params["filename"] |
178 try: |
174 statItems = params["st_names"] |
179 result = os.stat(params["filename"]) |
175 |
180 resultDict = {st: getattr(result, st) for st in params["st_names"]} |
176 try: |
|
177 result = os.stat(filename) |
|
178 resultDict = {st: getattr(result, st) for st in statItems} |
|
179 return {"ok": True, "result": resultDict} |
181 return {"ok": True, "result": resultDict} |
180 except OSError as err: |
182 except OSError as err: |
181 return { |
183 return { |
182 "ok": False, |
184 "ok": False, |
183 "error": str(err), |
185 "error": str(err), |
222 @param params dictionary containing the request data |
224 @param params dictionary containing the request data |
223 @type dict |
225 @type dict |
224 @return dictionary containing the reply data |
226 @return dictionary containing the reply data |
225 @rtype dict |
227 @rtype dict |
226 """ |
228 """ |
227 directory = params["directory"] |
229 try: |
228 |
230 os.mkdir(params["directory"]) |
229 try: |
231 return {"ok": True} |
230 os.makedirs(directory) |
232 except OSError as err: |
|
233 return { |
|
234 "ok": False, |
|
235 "error": str(err), |
|
236 } |
|
237 |
|
238 def __makedirs(self, params): |
|
239 """ |
|
240 Private method to create a new directory. |
|
241 |
|
242 @param params dictionary containing the request data |
|
243 @type dict |
|
244 @return dictionary containing the reply data |
|
245 @rtype dict |
|
246 """ |
|
247 try: |
|
248 os.makedirs(params["directory"], exist_ok=params["exist_ok"]) |
231 return {"ok": True} |
249 return {"ok": True} |
232 except OSError as err: |
250 except OSError as err: |
233 return { |
251 return { |
234 "ok": False, |
252 "ok": False, |
235 "error": str(err), |
253 "error": str(err), |
263 @param params dictionary containing the request data |
279 @param params dictionary containing the request data |
264 @type dict |
280 @type dict |
265 @return dictionary containing the reply data |
281 @return dictionary containing the reply data |
266 @rtype dict |
282 @rtype dict |
267 """ |
283 """ |
268 oldName = params["old_name"] |
284 try: |
269 newName = params["new_name"] |
285 os.replace(params["old_name"], params["new_name"]) |
270 |
|
271 try: |
|
272 os.replace(oldName, newName) |
|
273 return {"ok": True} |
286 return {"ok": True} |
274 except OSError as err: |
287 except OSError as err: |
275 return { |
288 return { |
276 "ok": False, |
289 "ok": False, |
277 "error": str(err), |
290 "error": str(err), |