libimobiledevice/libimobiledevice — pull request #160 by upbit (2014-12-13 05:31:13+00:00)
Title: cython: Add receive/receive_timeout methods for iDeviceConnection

Tested on iOS7.1.2/Python2.7:

~~~python
#!/usr/bin/env python

import sys
import plist
from imobiledevice import *

# modify from https://github.com/libimobiledevice/libimobiledevice/blob/master/dev/filerelaytest.c

def lockdown_get_service_client(service_class):
ld = LockdownClient(iDevice())
return ld.get_service_client(service_class)

def file_relay_get_UserDatabases():
filerelay = lockdown_get_service_client(FileRelayClient)
conn = filerelay.request_sources(["UserDatabases"])

sys.stdout.write("Write dump.cpio.gz:\n")
with open("dump.cpio.gz", "wb+") as dumpfile:
while (1):
try:
#data = conn.receive_timeout(4096, 10)
data = conn.receive(4096)
dumpfile.write(data)

sys.stdout.write(".")
except Exception, e:
if (e.code == -2):	# no more data
break
raise e

print "Done"

def main():
file_relay_get_UserDatabases()

if __name__ == '__main__':
main()
~~~