mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Added 'from __future__ import' to libimobiledevice.py, parse_xml.py
Tweaked a diagnostic printout in apple.driver.py
This commit is contained in:
parent
43668bbbd6
commit
7b9c3fd167
@ -320,6 +320,7 @@ class ITUNES(DriverBase):
|
||||
self.verbose = self.settings().extra_customization[self.DEBUG_LOGGING]
|
||||
if self.verbose:
|
||||
logger().info("%s.__init__():" % self.__class__.__name__)
|
||||
logger().info(" Debug logging enabled in iTunes plugin settings")
|
||||
|
||||
@property
|
||||
def cache_dir(self):
|
||||
|
@ -1,9 +1,12 @@
|
||||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
from __future__ import (unicode_literals, division, absolute_import,
|
||||
print_function)
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Gregory Riker'
|
||||
|
||||
|
||||
'''
|
||||
Wrapper for libiMobileDevice library based on API documentation at
|
||||
http://www.libimobiledevice.org/docs/html/globals.html
|
||||
@ -364,6 +367,13 @@ class libiMobileDevice():
|
||||
self._instproxy_client_options_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):
|
||||
'''
|
||||
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):
|
||||
if this_item.startswith('.'):
|
||||
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)
|
||||
self.current_dir = directory
|
||||
return file_stats
|
||||
@ -1321,27 +1334,27 @@ class libiMobileDevice():
|
||||
app_list = XmlPropertyListParser().parse(string_at(xml, xml_len.value))
|
||||
installed_apps = {}
|
||||
for app in app_list:
|
||||
if not applist:
|
||||
try:
|
||||
installed_apps[app['CFBundleName']] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']}
|
||||
except:
|
||||
installed_apps[app['CFBundleDisplayName']] = {'app_id': app['CFBundleDisplayName'], 'app_version': app['CFBundleDisplayName']}
|
||||
if 'CFBundleName' in app:
|
||||
app_name = app['CFBundleName']
|
||||
elif 'CFBundleDisplayName' in app:
|
||||
app_name = app['CFBundleDisplayName']
|
||||
elif 'CFBundleExecutable' in app:
|
||||
app_name = app['CFBundleExecutable']
|
||||
else:
|
||||
if 'CFBundleName' in app:
|
||||
if app['CFBundleName'] in applist:
|
||||
installed_apps[app['CFBundleName']] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']}
|
||||
if len(installed_apps) == len(app_list):
|
||||
break
|
||||
elif 'CFBundleDisplayName' in app:
|
||||
if app['CFBundleDisplayName'] in applist:
|
||||
installed_apps[app['CFBundleDisplayName']] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']}
|
||||
if len(installed_apps) == len(app_list):
|
||||
break
|
||||
else:
|
||||
self.log(" unable to find app name")
|
||||
for key in sorted(app.keys()):
|
||||
print(" %s \t %s" % (key, app[key]))
|
||||
continue
|
||||
self.log(" unable to find app name in bundle:")
|
||||
for key in sorted(app.keys()):
|
||||
self.log(" %s %s" % (repr(key), repr(app[key])))
|
||||
continue
|
||||
|
||||
if not applist:
|
||||
# Collecting all installed apps info
|
||||
installed_apps[app_name] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']}
|
||||
else:
|
||||
# Selectively collecting app info
|
||||
if app_name in applist:
|
||||
installed_apps[app['CFBundleName']] = {'app_id': app['CFBundleIdentifier'], 'app_version': app['CFBundleVersion']}
|
||||
if len(installed_apps) == len(app_list):
|
||||
break
|
||||
|
||||
if self.verbose:
|
||||
for app in sorted(installed_apps, key=lambda s: s.lower()):
|
||||
|
@ -1,4 +1,7 @@
|
||||
#!/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
|
||||
|
||||
@ -246,7 +249,7 @@ class XmlPropertyListParser(object):
|
||||
def _parse_using_etree(self, xml_input):
|
||||
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()
|
||||
try:
|
||||
for action, element in parser:
|
||||
|
Loading…
x
Reference in New Issue
Block a user