Пример #1
0
 def rcp(self, sources: List[str], destination: str) -> Response:
     return self.call(
         create_request(
             Requests.RCP, {
                 RequestsParams.RCP_SOURCES: sources,
                 RequestsParams.RCP_DESTINATION: destination
             }))
Пример #2
0
 def rshell(self, cmd: str, cols: int, rows: int) -> Response:
     return self.call(
         create_request(
             Requests.RSHELL, {
                 RequestsParams.RSHELL_CMD: cmd,
                 RequestsParams.RSHELL_COLS: cols,
                 RequestsParams.RSHELL_ROWS: rows
             }))
Пример #3
0
    def rcd(self, path) -> Response:
        resp = self.call(
            create_request(Requests.RCD, {RequestsParams.RCD_PATH: path}))

        if is_success_response(resp):
            self._rcwd = resp["data"]

        return resp
Пример #4
0
    def open(self, sharing_name) -> Response:
        resp = self.call(
            create_request(Requests.OPEN,
                           {RequestsParams.OPEN_SHARING: sharing_name}))

        if is_data_response(resp):
            self._connected_to_sharing = True
            self._sharing_info = resp["data"]
            self._rcwd = "/"
        # else?

        return resp
Пример #5
0
 def put(self,
         check: bool,
         preview: bool,
         dest: Optional[str] = None,
         is_multiple: Optional[bool] = None) -> Response:
     return self.call(
         create_request(
             Requests.PUT, {
                 RequestsParams.PUT_CHECK: check,
                 RequestsParams.PUT_PREVIEW: preview,
                 RequestsParams.PUT_DEST: dest,
                 RequestsParams.PUT_IS_MULTIPLE: is_multiple,
             }))
Пример #6
0
    def destroy_server_connection(self) -> Optional[Response]:
        log.d("Destroying server connection")
        resp = None
        if self._connected_to_server:
            try:
                log.d("Really sending disconnect()")
                resp = self.call(create_request(Requests.DISCONNECT))
            except:
                log.w("Failed to close sharing connection gracefully, "
                      "invaliding it anyway")

        self._connected_to_server = False
        return resp
Пример #7
0
 def rls(self,
         sort_by: List[str],
         reverse: bool = False,
         hidden: bool = False,
         details: bool = False,
         path: str = None) -> Response:
     return self.call(
         create_request(
             Requests.RLS, {
                 RequestsParams.RLS_PATH: path,
                 RequestsParams.RLS_SORT_BY: sort_by,
                 RequestsParams.RLS_REVERSE: reverse,
                 RequestsParams.RLS_HIDDEN: hidden,
                 RequestsParams.RLS_DETAILS: details
             }))
Пример #8
0
    def destroy_sharing_connection(self) -> Optional[Response]:
        log.d("Destroying sharing connection")
        resp = None
        if self._connected_to_sharing:
            try:
                log.d("Really sending close()")
                resp = self.call(create_request(Requests.CLOSE))
            except:
                log.w("Failed to close sharing connection gracefully, "
                      "invaliding it anyway")

        self._connected_to_sharing = False
        self._sharing_info = None
        self._rcwd = None
        return resp
Пример #9
0
    def connect(self, passwd) -> Response:
        # Compute user agent, not really used but is still an useful
        # information for debug what's happening
        useragent = f"es: {APP_VERSION} - "\
                    f"OS: {platform.system()} {platform.release()} - "\
                    f"Python: {platform.python_version()}"

        resp = self.call(
            create_request(
                Requests.CONNECT, {
                    RequestsParams.CONNECT_PASSWORD: passwd,
                    RequestsParams.CONNECT_USER_AGENT: useragent
                }))

        self._connected_to_server = is_success_response(resp)

        return resp
Пример #10
0
 def rtree(self,
           sort_by: List[str],
           reverse=False,
           hidden: bool = False,
           max_depth: int = int,
           details: bool = False,
           path: str = None) -> Response:
     return self.call(
         create_request(
             Requests.RTREE, {
                 RequestsParams.RTREE_PATH: path,
                 RequestsParams.RTREE_SORT_BY: sort_by,
                 RequestsParams.RTREE_REVERSE: reverse,
                 RequestsParams.RTREE_HIDDEN: hidden,
                 RequestsParams.RTREE_DEPTH: max_depth,
                 RequestsParams.RTREE_DETAILS: details
             }))
Пример #11
0
    def get(self,
            paths: List[str],
            check: bool,
            no_hidden: bool = False,
            mmap: Optional[bool] = None,
            chunk_size: Optional[int] = None) -> Response:

        req_params = {
            RequestsParams.GET_PATHS: paths,
            RequestsParams.GET_CHECK: check,
            RequestsParams.GET_NO_HIDDEN: no_hidden,
        }

        # Secret params
        if mmap is not None:
            req_params[RequestsParams.GET_MMAP] = mmap
        if chunk_size is not None:
            req_params[RequestsParams.GET_CHUNK_SIZE] = chunk_size

        return self.call(create_request(Requests.GET, req_params))
Пример #12
0
    def rfind(self,
              name: str = None,
              regex: str = None,
              case_sensitive: bool = True,
              ftype: FileType = None,
              details: bool = False,
              path: str = None,
              max_depth: int = None) -> Response:

        return self.call(
            create_request(
                Requests.RFIND, {
                    RequestsParams.RFIND_PATH: path,
                    RequestsParams.RFIND_NAME: name,
                    RequestsParams.RFIND_REGEX: regex,
                    RequestsParams.RFIND_CASE_SENSITIVE: case_sensitive,
                    RequestsParams.RFIND_FTYPE: ftype,
                    RequestsParams.RFIND_DETAILS: details,
                    RequestsParams.RFIND_MAX_DEPTH: max_depth,
                }))
Пример #13
0
 def rstat(self, paths: List[str]) -> Response:
     return self.call(
         create_request(Requests.RSTAT,
                        {RequestsParams.RSTAT_PATHS: paths}))
Пример #14
0
 def rrm(self, paths: List[str]) -> Response:
     return self.call(
         create_request(Requests.RRM, {RequestsParams.RRM_PATHS: paths}))
Пример #15
0
 def rmkdir(self, directory) -> Response:
     return self.call(
         create_request(Requests.RMKDIR,
                        {RequestsParams.RMKDIR_PATH: directory}))
Пример #16
0
    def rdu(self, path: str = None) -> Response:

        return self.call(
            create_request(Requests.RDU, {
                RequestsParams.RDU_PATH: path,
            }))
Пример #17
0
 def info(self) -> Response:
     return self.call(create_request(Requests.INFO))
Пример #18
0
 def list(self) -> Response:
     return self.call(create_request(Requests.LIST))
Пример #19
0
 def ping(self) -> Response:
     return self.call(create_request(Requests.PING))