Exemplo n.º 1
0
def crash_pull(lockdown, out):
    """ pull all crash reports """
    if not os.path.exists(out):
        os.makedirs(out)

    def log(src, dst):
        logging.info(f'{src} --> {dst}')

    afc = AfcService(lockdown, service_name='com.apple.crashreportcopymobile')
    afc.pull('/', out, callback=log)
Exemplo n.º 2
0
 def install_from_local(self, ipa_path, cmd='Install', options=None, handler=None, *args):
     if options is None:
         options = {}
     remote_path = posixpath.join('/', os.path.basename(ipa_path))
     afc = AfcService(self.lockdown)
     afc.set_file_contents(remote_path, open(ipa_path, 'rb').read())
     cmd = {'Command': cmd,
            'ClientOptions': options,
            'PackagePath': remote_path}
     self.service.send_plist(cmd)
     self.watch_completion(handler, args)
Exemplo n.º 3
0
def test_rm(lockdown):
    afc = AfcService(lockdown)
    afc.set_file_contents(TEST_FILENAME, b'')
    filenames = afc.listdir('/')
    assert TEST_FILENAME in filenames

    afc.rm(TEST_FILENAME)

    filenames = afc.listdir('/')
    assert TEST_FILENAME not in filenames
Exemplo n.º 4
0
def afc_rm(lockdown, remote_file):
    """ remove a file rooted at /var/mobile/Media """
    AfcService(lockdown=lockdown).rm(remote_file)
Exemplo n.º 5
0
def afc_ls(lockdown, remote_file, recursive):
    """ perform a dirlist rooted at /var/mobile/Media """
    show_dirlist(AfcService(lockdown=lockdown), remote_file, recursive=recursive)
Exemplo n.º 6
0
def afc_push(lockdown, local_file, remote_file):
    """ push local file into /var/mobile/Media """
    AfcService(lockdown=lockdown).set_file_contents(remote_file, local_file.read())
Exemplo n.º 7
0
def afc_pull(lockdown, remote_file, local_file):
    """ pull remote file from /var/mobile/Media """
    local_file.write(AfcService(lockdown=lockdown).get_file_contents(remote_file))
Exemplo n.º 8
0
def afc_rm(lockdown, remote_file):
    """ open an AFC shell rooted at /var/mobile/Media """
    AfcService(lockdown=lockdown).rm(remote_file)
Exemplo n.º 9
0
def afc_ls(lockdown, remote_file):
    """ open an AFC shell rooted at /var/mobile/Media """
    pprint(AfcService(lockdown=lockdown).listdir(remote_file))
Exemplo n.º 10
0
def afc_push(lockdown, local_file, remote_file):
    """ open an AFC shell rooted at /var/mobile/Media """
    AfcService(lockdown=lockdown).set_file_contents(remote_file,
                                                    local_file.read())
Exemplo n.º 11
0
def afc_pull(lockdown, remote_file, local_file):
    """ open an AFC shell rooted at /var/mobile/Media """
    local_file.write(
        AfcService(lockdown=lockdown).get_file_contents(remote_file))
Exemplo n.º 12
0
def crash_clear(lockdown):
    """ clear(/remove) all crash reports """
    afc = AfcService(lockdown, service_name='com.apple.crashreportcopymobile')
    afc.rm('/', force=True)
Exemplo n.º 13
0
def test_file_read_write(lockdown):
    afc = AfcService(lockdown)
    body = b'data'

    afc.set_file_contents(TEST_FILENAME, body)
    assert afc.get_file_contents(TEST_FILENAME) == body
Exemplo n.º 14
0
def test_ls(lockdown):
    afc = AfcService(lockdown)
    filenames = afc.listdir('/')
    assert 'DCIM' in filenames