Workaround for iTunes breaking scripting with version 10.6.3 on OS X. Fixes #1012243 (Cannot connect to update iTunes 10.6.3)

This commit is contained in:
Kovid Goyal 2012-06-27 20:36:00 +05:30
commit ff80d9c8ce

View File

@ -212,11 +212,8 @@ class ITUNES(DriverBase):
"for instructions on using 'Connect to iTunes'")
ITUNES_SANDBOX_LOCKOUT_MESSAGE = _(
'<p>Unable to communicate with iTunes.</p>'
"<p>As of iTunes version 10.6.3, application 'sandboxing' "
'was implemented by Apple, disabling inter-application communications '
'between iTunes and third-party applications.</p>'
'<p>Refer to the forum post '
'<a href="http://www.mobileread.com/forums/showpost.php?p=2113958&postcount=3">Apple implements sandboxing for iTunes 10.6.3</a> '
'<p>Refer to this '
'<a href="http://www.mobileread.com/forums/showpost.php?p=2113958&postcount=3">forum post</a> '
'for more information.</p>'
'<p></p>')
@ -232,8 +229,9 @@ class ITUNES(DriverBase):
# 0x12a0 iPhone 4S
# 0x12a2 iPad2 (GSM)
# 0x12a3 iPad2 (CDMA)
# 0x12a6 iPad3 (GSM)
VENDOR_ID = [0x05ac]
PRODUCT_ID = [0x1292,0x1293,0x1294,0x1297,0x1299,0x129a,0x129f,0x12a2,0x12a3]
PRODUCT_ID = [0x1292,0x1293,0x1294,0x1297,0x1299,0x129a,0x129f,0x12a2,0x12a3,0x12a6]
BCD = [0x01]
# Plugboard ID
@ -2362,6 +2360,8 @@ class ITUNES(DriverBase):
if isosx:
import appscript
as_name = appscript.__name__
as_version = appscript.__version__
'''
Launch iTunes if not already running
'''
@ -2383,18 +2383,25 @@ class ITUNES(DriverBase):
self.initial_status = 'already running'
'''
Test OSA. If we can't get the app name, we can't talk to iTunes.
As of iTunes 10.6.3 (June 2012), sandboxing was implemented disabling OSA
interapp communications.
Test OSA communication with iTunes.
If unable to communicate with iTunes, set self.iTunes to None, then
report to user in open()
'''
as_binding = "dynamic"
try:
# Try dynamic binding - works with iTunes <= 10.6.1
foo = self.iTunes.name()
except:
# Try static binding
import itunes
self.iTunes = appscript.app('iTunes',terms=itunes)
try:
foo = self.iTunes.name()
as_binding = "static"
except:
self.iTunes = None
if DEBUG:
logger().info(" unable to communicate with iTunes, raising dialog to user")
logger().info(" unable to communicate with iTunes via %s %s using any binding" % (as_name, as_version))
return
'''
@ -2415,6 +2422,7 @@ class ITUNES(DriverBase):
logger().info(" [OSX %s - %s (%s), driver version %d.%d.%d]" %
(self.iTunes.name(), self.iTunes.version(), self.initial_status,
self.version[0],self.version[1],self.version[2]))
logger().info(" communicating with iTunes via %s %s using %s binding" % (as_name, as_version, as_binding))
logger().info(" calibre_library_path: %s" % self.calibre_library_path)
if iswindows: