From 11dee1a63030fc5d1e459cac88e7f2716a7811f6 Mon Sep 17 00:00:00 2001 From: DB Date: Sat, 1 Feb 2014 15:57:41 +0100 Subject: [PATCH] Fix a bug with non ascii characters (tested on: mdf debug applist) Allow to use com.apple.afc if com.apple.afc2 is not present (in order to work with non-jailbroken devices) --- CoreFoundation.py | 2 +- afcroot.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CoreFoundation.py b/CoreFoundation.py index af3e643..d737503 100644 --- a/CoreFoundation.py +++ b/CoreFoundation.py @@ -466,7 +466,7 @@ def CFTypeTo(value): bufsize = CFStringGetMaximumSizeForEncoding(l, kCFStringEncodingUTF8) + 1 buf = create_string_buffer(bufsize) CFStringGetCString(value, buf, bufsize, kCFStringEncodingUTF8) - retval = buf.value + retval = buf.value.decode("utf8") elif typeid == CFDataGetTypeID(): retval = string_at(CFDataGetBytePtr(value), CFDataGetLength(value)) diff --git a/afcroot.py b/afcroot.py index e14a182..71c49b9 100644 --- a/afcroot.py +++ b/afcroot.py @@ -28,8 +28,11 @@ class AFCRoot(AFC): def __init__(self, amdevice): - s = amdevice.start_service(u'com.apple.afc2') + try: + s = amdevice.start_service(u'com.apple.afc2') + except RuntimeError: + s = amdevice.start_service(u'com.apple.afc') if s is None: - raise RuntimeError(u'Unable to launch:', u'com.apple.afc2') + raise RuntimeError(u'Unable to launch:', u'com.apple.afc / com.apple.afc2') AFC.__init__(self, s)