Skip to content

Commit

Permalink
Merge pull request #338 from doronz88/bugfix/pull-file
Browse files Browse the repository at this point in the history
Bugfix/pull file
  • Loading branch information
doronz88 authored Jan 21, 2024
2 parents d12aae3 + 912f343 commit d2cc5b0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
20 changes: 6 additions & 14 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,15 @@ jobs:
python -m pip install isort
isort . -m HANGING_INDENT -l 120 --check-only
- name: Build
# TODO: remove when lief releases the 3.12 wheel (https://github.com/lief-project/LIEF/issues/990)
if: matrix.python-version != 3.12
run: |
python3 -m pip install mypy-protobuf protobuf grpcio-tools
make -C ../protos/ python_protos
python -m pip install build
python3 -m build
- name: Install
# TODO: remove when lief releases the 3.12 wheel (https://github.com/lief-project/LIEF/issues/990)
if: matrix.python-version != 3.12
run: |
python3 -m pip install .
- name: Run help
# TODO: remove when lief releases the 3.12 wheel (https://github.com/lief-project/LIEF/issues/990)
if: matrix.python-version != 3.12
run: |
python3 -m rpcclient --help
Expand Down Expand Up @@ -124,10 +118,9 @@ jobs:
- os: macos-latest
arch: arm64
python-version: "3.11"
# TODO: remove when lief releases the 3.12 wheel (https://github.com/lief-project/LIEF/issues/990)
# - os: macos-latest
# arch: arm64
# python-version: "3.12"
- os: macos-latest
arch: arm64
python-version: "3.12"

- os: macos-latest
arch: x86_64
Expand All @@ -141,10 +134,9 @@ jobs:
- os: macos-latest
arch: x86_64
python-version: "3.11"
# TODO: remove when lief releases the 3.12 wheel (https://github.com/lief-project/LIEF/issues/990)
# - os: macos-latest
# arch: x86_64
# python-version: "3.12"
- os: macos-latest
arch: x86_64
python-version: "3.12"

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions src/rpcclient/rpcclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ def shell(self, reuse_client: bool = False):
try:
logging.getLogger('parso.python.diff').disabled = True
logging.getLogger('parso.cache').disabled = True
logging.getLogger('asyncio').disabled = True
xonsh_main(args)
except SystemExit:
self._logger.disabled = False
Expand Down
23 changes: 15 additions & 8 deletions src/rpcclient/rpcclient/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,16 @@ def __repr__(self):

class RemotePath(PosixPath):
def __init__(self, path: str, client) -> None:
super().__init__()
try:
super().__init__(path) # solution from python3.12 since signature has changed
except TypeError:
super().__init__()

self._path = path
self._client = client

def __new__(cls, path: str, client):
# this will not be needed once python3.11 is deprecated since it is now possible to subclass normally
return super().__new__(cls, *[path])

def chmod(self, mode: int):
Expand Down Expand Up @@ -285,7 +290,7 @@ def _cp(self, sources: List[Path], dest: Path, recursive: bool, force: bool):
dest_exists = dest.exists()
is_dest_dir = dest_exists and dest.is_dir()

if ((not dest_exists or not is_dest_dir) and len(sources) > 1):
if (not dest_exists or not is_dest_dir) and (len(sources) > 1):
raise ArgumentError(f'target {dest} is not a directory')

if recursive:
Expand Down Expand Up @@ -481,21 +486,23 @@ def read_file(self, file: str) -> bytes:
def _remote_path(self, path: str) -> RemotePath:
return RemotePath(path, self._client)

@path_to_str('remotes')
@path_to_str('local')
def pull(self, remotes: Union[List[str], str], local: str, recursive: bool = False, force: bool = False):
def pull(self, remotes: Union[List[Union[str, Path]], Union[str, Path]], local: str, recursive: bool = False,
force: bool = False):
""" pull complete directory tree """
if not isinstance(remotes, list):
remotes = [remotes]
self._cp([self._remote_path(remote) for remote in remotes], Path(str(local)), recursive, force)
remotes_str = [str(remote) for remote in remotes]
self._cp([self._remote_path(remote) for remote in remotes_str], Path(str(local)), recursive, force)

@path_to_str('locals')
@path_to_str('remote')
def push(self, locals: Union[List[str], str], remote: str, recursive: bool = False, force: bool = False):
def push(self, locals: Union[List[Union[str, Path]], Union[str, Path]], remote: str, recursive: bool = False,
force: bool = False):
""" push complete directory tree """
if not isinstance(locals, list):
locals = [locals]
self._cp([Path(str(local)) for local in locals], self._remote_path(remote), recursive, force)
locals_str = [str(local) for local in locals]
self._cp([Path(str(local)) for local in locals_str], self._remote_path(remote), recursive, force)

@path_to_str('file')
def touch(self, file: str, mode: int = None):
Expand Down

0 comments on commit d2cc5b0

Please sign in to comment.