Added 'from __future__ import' to libimobiledevice.py, parse_xml.py

Tweaked a diagnostic printout in apple.driver.py
This commit is contained in:
GRiker 2013-05-15 09:27:27 -06:00
parent 43668bbbd6
commit 7b9c3fd167
3 changed files with 39 additions and 22 deletions

View File

@ -320,6 +320,7 @@ class ITUNES(DriverBase):
self.verbose = self.settings().extra_customization[self.DEBUG_LOGGING] self.verbose = self.settings().extra_customization[self.DEBUG_LOGGING]
if self.verbose: if self.verbose:
logger().info("%s.__init__():" % self.__class__.__name__) logger().info("%s.__init__():" % self.__class__.__name__)
logger().info(" Debug logging enabled in iTunes plugin settings")
@property @property
def cache_dir(self): def cache_dir(self):

View File

@ -1,9 +1,12 @@
#!/usr/bin/env python #!/usr/bin/env python
# coding: utf-8 # coding: utf-8
from __future__ import (unicode_literals, division, absolute_import,
print_function)
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2013, Gregory Riker' __copyright__ = '2013, Gregory Riker'
''' '''
Wrapper for libiMobileDevice library based on API documentation at Wrapper for libiMobileDevice library based on API documentation at
http://www.libimobiledevice.org/docs/html/globals.html http://www.libimobiledevice.org/docs/html/globals.html
@ -364,6 +367,13 @@ class libiMobileDevice():
self._instproxy_client_options_free() self._instproxy_client_options_free()
self._instproxy_client_free() self._instproxy_client_free()
def get_preferences(self):
'''
Get a partial list device-specific information
'''
self._log_location()
return self._lockdown_get_value()
def listdir(self, path): def listdir(self, path):
''' '''
Return a list containing the names of the entries in the iOS directory Return a list containing the names of the entries in the iOS directory
@ -1032,7 +1042,10 @@ class libiMobileDevice():
for i, this_item in enumerate(dir_list): for i, this_item in enumerate(dir_list):
if this_item.startswith('.'): if this_item.startswith('.'):
continue continue
path = '/'.join([directory, this_item]) if directory == '/':
path = '/' + this_item
else:
path = '/'.join([directory, this_item])
file_stats[os.path.basename(path)] = self._afc_get_file_info(path) file_stats[os.path.basename(path)] = self._afc_get_file_info(path)
self.current_dir = directory self.current_dir = directory
return file_stats return file_stats
@ -1321,27 +1334,27 @@ class libiMobileDevice():
app_list = XmlPropertyListParser().parse(string_at(xml, xml_len.value)) app_list = XmlPropertyListParser().parse(string_at(xml, xml_len.value))
installed_apps = {} installed_apps = {}
for app in app_list: for app in app_list:
if not applist: if 'CFBundleName' in app:
try: app_name = app['CFBundleName']
installed_apps[app['CFBundleName']] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']} elif 'CFBundleDisplayName' in app:
except: app_name = app['CFBundleDisplayName']
installed_apps[app['CFBundleDisplayName']] = {'app_id': app['CFBundleDisplayName'], 'app_version': app['CFBundleDisplayName']} elif 'CFBundleExecutable' in app:
app_name = app['CFBundleExecutable']
else: else:
if 'CFBundleName' in app: self.log(" unable to find app name in bundle:")
if app['CFBundleName'] in applist: for key in sorted(app.keys()):
installed_apps[app['CFBundleName']] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']} self.log(" %s %s" % (repr(key), repr(app[key])))
if len(installed_apps) == len(app_list): continue
break
elif 'CFBundleDisplayName' in app: if not applist:
if app['CFBundleDisplayName'] in applist: # Collecting all installed apps info
installed_apps[app['CFBundleDisplayName']] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']} installed_apps[app_name] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']}
if len(installed_apps) == len(app_list): else:
break # Selectively collecting app info
else: if app_name in applist:
self.log(" unable to find app name") installed_apps[app['CFBundleName']] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']}
for key in sorted(app.keys()): if len(installed_apps) == len(app_list):
print(" %s \t %s" % (key, app[key])) break
continue
if self.verbose: if self.verbose:
for app in sorted(installed_apps, key=lambda s: s.lower()): for app in sorted(installed_apps, key=lambda s: s.lower()):

View File

@ -1,4 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import (unicode_literals, division, absolute_import,
print_function)
""" """
https://github.com/ishikawa/python-plist-parser/blob/master/plist_parser.py https://github.com/ishikawa/python-plist-parser/blob/master/plist_parser.py
@ -246,7 +249,7 @@ class XmlPropertyListParser(object):
def _parse_using_etree(self, xml_input): def _parse_using_etree(self, xml_input):
from xml.etree.cElementTree import iterparse from xml.etree.cElementTree import iterparse
parser = iterparse(self._to_stream(xml_input), events=('start', 'end')) parser = iterparse(self._to_stream(xml_input), events=(b'start', b'end'))
self.startDocument() self.startDocument()
try: try:
for action, element in parser: for action, element in parser: