Skip to content

Commit

Permalink
refactor: split darwin into ios and macos
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Feb 14, 2022
1 parent d2a1758 commit 8ebfc36
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/rpcclient/rpcclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def _execution_loop(self, stdin=sys.stdin, stdout=sys.stdout):
return exitcode_t.parse(data)

def __repr__(self):
buf = '<'
buf = f'<{self.__class__.__name__} '
buf += f'PID:{self.symbols.getpid():d} UID:{self.symbols.getuid():d} GID:{self.symbols.getgid():d} ' \
f'SYSNAME:{self._sysname}'
buf += '>'
Expand Down
9 changes: 8 additions & 1 deletion src/rpcclient/rpcclient/client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

from rpcclient.client import Client
from rpcclient.darwin.client import DarwinClient
from rpcclient.ios.client import IosClient
from rpcclient.linux.client import LinuxClient
from rpcclient.exceptions import FailedToConnectError
from rpcclient.macos.client import MacosClient
from rpcclient.protocol import UNAME_VERSION_LEN, DEFAULT_PORT


Expand All @@ -31,7 +33,12 @@ def create_client(hostname: str, port: int = DEFAULT_PORT):
logging.info(f'connection uname.sysname: {sysname}')

if sysname == 'darwin':
return DarwinClient(sock, sysname, hostname, port)
client = DarwinClient(sock, sysname, hostname, port)

if client.uname.machine.startswith('iPhone'):
return IosClient(sock, sysname, hostname, port)
else:
return MacosClient(sock, sysname, hostname, port)
elif sysname == 'linux':
return LinuxClient(sock, sysname, hostname, port)

Expand Down
Empty file.
5 changes: 5 additions & 0 deletions src/rpcclient/rpcclient/ios/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from rpcclient.darwin.client import DarwinClient


class IosClient(DarwinClient):
pass
Empty file.
5 changes: 5 additions & 0 deletions src/rpcclient/rpcclient/macos/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from rpcclient.darwin.client import DarwinClient


class MacosClient(DarwinClient):
pass

0 comments on commit 8ebfc36

Please sign in to comment.