Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The methods mkdir, mv, copy and symlink will return with the path of the new file/directory instead of None #83

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions firecrest/AsyncClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,9 @@ async def list_files(

async def mkdir(
self, machine: str, target_path: str, p: Optional[bool] = None
) -> None:
) -> str:
"""Creates a new directory.
When successful, the method returns a string with the path of the newly created directory.

:param machine: the machine name where the filesystem belongs to
:param target_path: the absolute target path
Expand All @@ -611,9 +612,11 @@ async def mkdir(
data=data,
)
self._json_response([resp], 201)
return target_path

async def mv(self, machine: str, source_path: str, target_path: str) -> None:
async def mv(self, machine: str, source_path: str, target_path: str) -> str:
"""Rename/move a file, directory, or symlink at the `source_path` to the `target_path` on `machine`'s filesystem.
When successful, the method returns a string with the new path of the file.

:param machine: the machine name where the filesystem belongs to
:param source_path: the absolute source path
Expand All @@ -626,6 +629,7 @@ async def mv(self, machine: str, source_path: str, target_path: str) -> None:
data={"targetPath": target_path, "sourcePath": source_path},
)
self._json_response([resp], 200)
return target_path

async def chmod(self, machine: str, target_path: str, mode: str) -> None:
"""Changes the file mod bits of a given file according to the specified mode.
Expand Down Expand Up @@ -675,8 +679,9 @@ async def chown(
)
self._json_response([resp], 200)

async def copy(self, machine: str, source_path: str, target_path: str) -> None:
async def copy(self, machine: str, source_path: str, target_path: str) -> str:
"""Copies file from `source_path` to `target_path`.
When successful, the method returns a string with the path of the newly created file.

:param machine: the machine name where the filesystem belongs to
:param source_path: the absolute source path
Expand All @@ -689,6 +694,7 @@ async def copy(self, machine: str, source_path: str, target_path: str) -> None:
data={"targetPath": target_path, "sourcePath": source_path},
)
self._json_response([resp], 201)
return target_path

async def file_type(self, machine: str, target_path: str) -> str:
"""Uses the `file` linux application to determine the type of a file.
Expand Down Expand Up @@ -726,8 +732,9 @@ async def stat(
)
return self._json_response([resp], 200)["output"]

async def symlink(self, machine: str, target_path: str, link_path: str) -> None:
async def symlink(self, machine: str, target_path: str, link_path: str) -> str:
"""Creates a symbolic link.
When successful, the method returns a string with the path of the newly created link.

:param machine: the machine name where the filesystem belongs to
:param target_path: the absolute path that the symlink will point to
Expand All @@ -740,6 +747,7 @@ async def symlink(self, machine: str, target_path: str, link_path: str) -> None:
data={"targetPath": target_path, "linkPath": link_path},
)
self._json_response([resp], 201)
return target_path

async def simple_download(
self, machine: str, source_path: str, target_path: str | pathlib.Path | BytesIO
Expand Down
16 changes: 12 additions & 4 deletions firecrest/BasicClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,9 @@ def list_files(
)
return self._json_response([resp], 200)["output"]

def mkdir(self, machine: str, target_path: str, p: Optional[bool] = None) -> None:
def mkdir(self, machine: str, target_path: str, p: Optional[bool] = None) -> str:
"""Creates a new directory.
When successful, the method returns a string with the path of the newly created directory.

:param machine: the machine name where the filesystem belongs to
:param target_path: the absolute target path
Expand All @@ -437,9 +438,11 @@ def mkdir(self, machine: str, target_path: str, p: Optional[bool] = None) -> Non
data=data,
)
self._json_response([resp], 201)
return target_path

def mv(self, machine: str, source_path: str, target_path: str) -> None:
def mv(self, machine: str, source_path: str, target_path: str) -> str:
"""Rename/move a file, directory, or symlink at the `source_path` to the `target_path` on `machine`'s filesystem.
When successful, the method returns a string with the new path of the file.

:param machine: the machine name where the filesystem belongs to
:param source_path: the absolute source path
Expand All @@ -452,6 +455,7 @@ def mv(self, machine: str, source_path: str, target_path: str) -> None:
data={"targetPath": target_path, "sourcePath": source_path},
)
self._json_response([resp], 200)
return target_path

def chmod(self, machine: str, target_path: str, mode: str) -> None:
"""Changes the file mod bits of a given file according to the specified mode.
Expand Down Expand Up @@ -501,8 +505,9 @@ def chown(
)
self._json_response([resp], 200)

def copy(self, machine: str, source_path: str, target_path: str) -> None:
def copy(self, machine: str, source_path: str, target_path: str) -> str:
"""Copies file from `source_path` to `target_path`.
When successful, the method returns a string with the path of the newly created file.

:param machine: the machine name where the filesystem belongs to
:param source_path: the absolute source path
Expand All @@ -515,6 +520,7 @@ def copy(self, machine: str, source_path: str, target_path: str) -> None:
data={"targetPath": target_path, "sourcePath": source_path},
)
self._json_response([resp], 201)
return target_path

def file_type(self, machine: str, target_path: str) -> str:
"""Uses the `file` linux application to determine the type of a file.
Expand Down Expand Up @@ -552,8 +558,9 @@ def stat(
)
return self._json_response([resp], 200)["output"]

def symlink(self, machine: str, target_path: str, link_path: str) -> None:
def symlink(self, machine: str, target_path: str, link_path: str) -> str:
"""Creates a symbolic link.
When successful, the method returns a string with the path of the newly created link.

:param machine: the machine name where the filesystem belongs to
:param target_path: the absolute path that the symlink will point to
Expand All @@ -566,6 +573,7 @@ def symlink(self, machine: str, target_path: str, link_path: str) -> None:
data={"targetPath": target_path, "linkPath": link_path},
)
self._json_response([resp], 201)
return target_path

def simple_download(
self, machine: str, source_path: str, target_path: str | pathlib.Path | BytesIO
Expand Down
Loading