Skip to content

Commit

Permalink
Merge pull request #7 from doronz88/refactor/afc
Browse files Browse the repository at this point in the history
afc: refactor afc service
  • Loading branch information
doronz88 authored Apr 19, 2021
2 parents 2e123b2 + 081c45a commit 7926660
Show file tree
Hide file tree
Showing 10 changed files with 141 additions and 133 deletions.
14 changes: 7 additions & 7 deletions pymobiledevice3/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pygments import highlight, lexers, formatters
from termcolor import colored

from pymobiledevice3.afc import AFCShell, AFCClient
from pymobiledevice3.services.afc import AfcShell, AfcService
from pymobiledevice3.lockdown import LockdownClient
from pymobiledevice3.services.diagnostics import DiagnosticsService
from pymobiledevice3.services.dvt_secure_socket_proxy import DvtSecureSocketProxyService
Expand Down Expand Up @@ -371,7 +371,7 @@ def crash(lockdown, action):
ack = b'ping\x00'
assert ack == lockdown.start_service('com.apple.crashreportmover').recv_exact(len(ack))
elif action == 'shell':
AFCShell(lockdown=lockdown, afcname='com.apple.crashreportcopymobile').cmdloop()
AfcShell(lockdown=lockdown, afcname='com.apple.crashreportcopymobile').cmdloop()


@cli.group()
Expand All @@ -383,37 +383,37 @@ def afc():
@afc.command('shell', cls=Command)
def afc_shell(lockdown):
""" open an AFC shell rooted at /var/mobile/Media """
AFCShell(lockdown=lockdown, afcname='com.apple.afc').cmdloop()
AfcShell(lockdown=lockdown, afcname='com.apple.afc').cmdloop()


@afc.command('pull', cls=Command)
@click.argument('remote_file', type=click.Path(exists=False))
@click.argument('local_file', type=click.File('wb'))
def afc_pull(lockdown, remote_file, local_file):
""" open an AFC shell rooted at /var/mobile/Media """
local_file.write(AFCClient(lockdown=lockdown).get_file_contents(remote_file))
local_file.write(AfcService(lockdown=lockdown).get_file_contents(remote_file))


@afc.command('push', cls=Command)
@click.argument('local_file', type=click.File('rb'))
@click.argument('remote_file', type=click.Path(exists=False))
def afc_push(lockdown, local_file, remote_file):
""" open an AFC shell rooted at /var/mobile/Media """
AFCClient(lockdown=lockdown).set_file_contents(remote_file, local_file.read())
AfcService(lockdown=lockdown).set_file_contents(remote_file, local_file.read())


@afc.command('ls', cls=Command)
@click.argument('remote_file', type=click.Path(exists=False))
def afc_ls(lockdown, remote_file):
""" open an AFC shell rooted at /var/mobile/Media """
pprint(AFCClient(lockdown=lockdown).read_directory(remote_file))
pprint(AfcService(lockdown=lockdown).listdir(remote_file))


@afc.command('rm', cls=Command)
@click.argument('remote_file', type=click.Path(exists=False))
def afc_rm(lockdown, remote_file):
""" open an AFC shell rooted at /var/mobile/Media """
AFCClient(lockdown=lockdown).file_remove(remote_file)
AfcService(lockdown=lockdown).rm(remote_file)


@cli.command(cls=Command)
Expand Down
Loading

0 comments on commit 7926660

Please sign in to comment.