46 "Exists": self.__exists, |
47 "Exists": self.__exists, |
47 "Access": self.__access, |
48 "Access": self.__access, |
48 "ReadFile": self.__readFile, |
49 "ReadFile": self.__readFile, |
49 "WriteFile": self.__writeFile, |
50 "WriteFile": self.__writeFile, |
50 "DirEntries": self.__dirEntries, |
51 "DirEntries": self.__dirEntries, |
|
52 "ExpandUser": self.__expanduser, |
|
53 "ShutilCopy": self.__shutilCopy, |
51 } |
54 } |
52 |
55 |
53 def handleRequest(self, request, params, reqestUuid): |
56 def handleRequest(self, request, params, reqestUuid): |
54 """ |
57 """ |
55 Public method handling the received file system requests. |
58 Public method handling the received file system requests. |
398 ) |
401 ) |
399 return { |
402 return { |
400 "ok": True, |
403 "ok": True, |
401 "result": result, |
404 "result": result, |
402 } |
405 } |
|
406 |
|
407 def __expanduser(self, params): |
|
408 """ |
|
409 Private method to replace an initial component of ~ or ~user replaced. |
|
410 |
|
411 @param params dictionary containing the request data |
|
412 @type dict |
|
413 @return dictionary containing the reply data |
|
414 @rtype dict |
|
415 """ |
|
416 return { |
|
417 "ok": True, |
|
418 "name": os.path.expanduser(params["name"]) |
|
419 } |
|
420 |
|
421 def __shutilCopy(self, params): |
|
422 """ |
|
423 Private method to copy a source file to a destination file or directory. |
|
424 |
|
425 @param params dictionary containing the request data |
|
426 @type dict |
|
427 @return dictionary containing the reply data |
|
428 @rtype dict |
|
429 """ |
|
430 try: |
|
431 return { |
|
432 "ok": True, |
|
433 "dst": shutil.copy(params["src_name"], params["dst_name"]), |
|
434 } |
|
435 except OSError as err: |
|
436 return { |
|
437 "ok": False, |
|
438 "error": str(err), |
|
439 } |