mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Fix libimobiledevice failing to load library on unsupported linux builds
Also some pep8 cleanup
This commit is contained in:
parent
b4c908104f
commit
ceed1a1667
@ -20,12 +20,13 @@ from ctypes import (
|
||||
c_char, c_char_p, c_int, c_long, c_ubyte, c_uint, c_ulonglong, c_void_p,
|
||||
POINTER, string_at, Structure)
|
||||
|
||||
from calibre.constants import DEBUG, islinux, isosx, iswindows
|
||||
from calibre.constants import DEBUG, isosx, iswindows
|
||||
from calibre.devices.idevice.parse_xml import XmlPropertyListParser
|
||||
from calibre.devices.usbms.driver import debug_print
|
||||
|
||||
|
||||
class libiMobileDeviceException(Exception):
|
||||
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
@ -34,6 +35,7 @@ class libiMobileDeviceException(Exception):
|
||||
|
||||
|
||||
class libiMobileDeviceIOException(Exception):
|
||||
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
@ -42,6 +44,7 @@ class libiMobileDeviceIOException(Exception):
|
||||
|
||||
|
||||
class AFC_CLIENT_T(Structure):
|
||||
|
||||
'''
|
||||
http://www.libimobiledevice.org/docs/html/structafc__client__private.html
|
||||
'''
|
||||
@ -74,6 +77,7 @@ class AFC_CLIENT_T(Structure):
|
||||
|
||||
|
||||
class HOUSE_ARREST_CLIENT_T(Structure):
|
||||
|
||||
'''
|
||||
http://www.libimobiledevice.org/docs/html/structhouse__arrest__client__private.html
|
||||
'''
|
||||
@ -94,6 +98,7 @@ class HOUSE_ARREST_CLIENT_T(Structure):
|
||||
|
||||
|
||||
class IDEVICE_T(Structure):
|
||||
|
||||
'''
|
||||
http://www.libimobiledevice.org/docs/html/structidevice__private.html
|
||||
'''
|
||||
@ -104,6 +109,7 @@ class IDEVICE_T(Structure):
|
||||
|
||||
|
||||
class INSTPROXY_CLIENT_T(Structure):
|
||||
|
||||
'''
|
||||
http://www.libimobiledevice.org/docs/html/structinstproxy__client__private.html
|
||||
'''
|
||||
@ -129,6 +135,7 @@ class INSTPROXY_CLIENT_T(Structure):
|
||||
|
||||
|
||||
class LOCKDOWND_CLIENT_T(Structure):
|
||||
|
||||
'''
|
||||
http://www.libimobiledevice.org/docs/html/structlockdownd__client__private.html
|
||||
'''
|
||||
@ -152,6 +159,7 @@ class LOCKDOWND_CLIENT_T(Structure):
|
||||
|
||||
|
||||
class LOCKDOWND_SERVICE_DESCRIPTOR(Structure):
|
||||
|
||||
'''
|
||||
from libimobiledevice/include/libimobiledevice/lockdown.h
|
||||
'''
|
||||
@ -162,6 +170,7 @@ class LOCKDOWND_SERVICE_DESCRIPTOR(Structure):
|
||||
|
||||
|
||||
class libiMobileDevice():
|
||||
|
||||
'''
|
||||
Wrapper for libiMobileDevice
|
||||
'''
|
||||
@ -438,10 +447,10 @@ class libiMobileDevice():
|
||||
return self._afc_read_directory(path, get_stats=get_stats)
|
||||
|
||||
def load_library(self):
|
||||
if islinux:
|
||||
env = "linux"
|
||||
self.lib = cdll.LoadLibrary('libimobiledevice.so.5')
|
||||
self.plist_lib = cdll.LoadLibrary('libplist.so.3')
|
||||
if iswindows:
|
||||
env = "Windows"
|
||||
self.lib = cdll.LoadLibrary('libimobiledevice.dll')
|
||||
self.plist_lib = cdll.LoadLibrary('libplist.dll')
|
||||
elif isosx:
|
||||
env = "OS X"
|
||||
|
||||
@ -458,11 +467,13 @@ class libiMobileDevice():
|
||||
self.plist_lib = cdll.LoadLibrary(os.path.join(getattr(sys, 'frameworks_dir'), path))
|
||||
else:
|
||||
self.plist_lib = cdll.LoadLibrary(path)
|
||||
elif iswindows:
|
||||
env = "Windows"
|
||||
self.lib = cdll.LoadLibrary('libimobiledevice.dll')
|
||||
self.plist_lib = cdll.LoadLibrary('libplist.dll')
|
||||
|
||||
else:
|
||||
env = "linux"
|
||||
try:
|
||||
self.lib = cdll.LoadLibrary('libimobiledevice.so.5')
|
||||
except EnvironmentError:
|
||||
self.lib = cdll.LoadLibrary('libimobiledevice.so')
|
||||
self.plist_lib = cdll.LoadLibrary('libplist.so.3')
|
||||
self._log_location(env)
|
||||
self._log(" libimobiledevice loaded from '{0}'".format(self.lib._name))
|
||||
self._log(" libplist loaded from '{0}'".format(self.plist_lib._name))
|
||||
@ -506,7 +517,7 @@ class libiMobileDevice():
|
||||
self._instproxy_client_options_free()
|
||||
self._instproxy_client_free()
|
||||
|
||||
if not app_name in self.installed_apps:
|
||||
if app_name not in self.installed_apps:
|
||||
self._log(" {0} not installed on this iDevice".format(repr(app_name)))
|
||||
self.disconnect_idevice()
|
||||
else:
|
||||
@ -1719,7 +1730,6 @@ class libiMobileDevice():
|
||||
return device_name
|
||||
|
||||
def _lockdown_get_value(self, requested_items=[]):
|
||||
|
||||
'''
|
||||
Retrieves a preferences plist using an optional domain and/or key name.
|
||||
|
||||
@ -1937,4 +1947,3 @@ class libiMobileDevice():
|
||||
|
||||
def __null(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user