Skip to content

Commit

Permalink
feat(pyd): implement remove across backends.
Browse files Browse the repository at this point in the history
Signed-off-by: Braden Mars <bradenmars@bradenmars.me>
  • Loading branch information
BradenM committed Apr 17, 2023
1 parent 8b7a255 commit f0bba8d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions micropy/pyd/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def pull_file(
def list_dir(self, path: DevicePath) -> list[DevicePath]:
...

@abc.abstractmethod
def remove(self, path: DevicePath) -> None:
...

@abc.abstractmethod
def copy_dir(
self,
Expand Down
3 changes: 3 additions & 0 deletions micropy/pyd/backend_rshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,6 @@ def eval_script(
raise Exception(str(e)) from e
out = out_bytes.decode("utf-8")
return out

def remove(self, path: DevicePath) -> None:
self._rsh.rm(str(path))
3 changes: 3 additions & 0 deletions micropy/pyd/backend_upydevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,6 @@ def eval_script(
self.write_file(contents, DevicePath(_target_path), consumer=consumer)
self.eval(f"import {Path(_target_path).stem}", consumer=consumer)
self.uos.remove(str(_target_path))

def remove(self, path: DevicePath) -> None:
self.uos.remove(str(path))
3 changes: 3 additions & 0 deletions micropy/pyd/pydevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ def copy_to(self, source_path: HostPath, target_path: DevicePath, **kwargs) -> N
raise RuntimeError("Copying dirs to device is not yet supported!")
return self.pydevice.push_file(source_path, target_path, consumer=self.consumer, **kwargs)

def remove(self, target_path: DevicePath) -> None:
return self.pydevice.remove(target_path)

def connect(self):
return self.pydevice.connect()

Expand Down

0 comments on commit f0bba8d

Please sign in to comment.