mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
...
This commit is contained in:
commit
aefbf2ac1f
@ -224,16 +224,19 @@ class libiMobileDevice():
|
|||||||
|
|
||||||
def copy_to_iDevice(self, src, dst):
|
def copy_to_iDevice(self, src, dst):
|
||||||
'''
|
'''
|
||||||
High-level convenience method to copy src on local filesystem to
|
High-level convenience method to copy src from local filesystem to
|
||||||
dst on iDevice.
|
dst on iDevice.
|
||||||
|
Assumed to be a binary file (epub, sqlite, etc)
|
||||||
src: file on local filesystem
|
src: file on local filesystem
|
||||||
dst: file to be created on iOS filesystem
|
dst: file to be created on iOS filesystem
|
||||||
'''
|
'''
|
||||||
self._log_location("src='%s', dst='%s'" % (src, dst))
|
self._log_location("src=%s, dst=%s" % (repr(src), repr(dst)))
|
||||||
with open(src) as f:
|
mode = 'rb'
|
||||||
|
with open(src, mode) as f:
|
||||||
content = bytearray(f.read())
|
content = bytearray(f.read())
|
||||||
|
|
||||||
mode = 'wb'
|
mode = 'wb'
|
||||||
handle = self._afc_file_open(dst, mode=mode)
|
handle = self._afc_file_open(str(dst), mode=mode)
|
||||||
if handle is not None:
|
if handle is not None:
|
||||||
success = self._afc_file_write(handle, content, mode=mode)
|
success = self._afc_file_write(handle, content, mode=mode)
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
@ -800,7 +803,7 @@ class libiMobileDevice():
|
|||||||
error: (afc_error_t) AFC_E_SUCCESS (0) on success or AFC_E_* error value
|
error: (afc_error_t) AFC_E_SUCCESS (0) on success or AFC_E_* error value
|
||||||
|
|
||||||
'''
|
'''
|
||||||
self._log_location("'%s', mode='%s'" % (filename, mode))
|
self._log_location("%s, mode='%s'" % (repr(filename), mode))
|
||||||
|
|
||||||
handle = c_ulonglong(0)
|
handle = c_ulonglong(0)
|
||||||
|
|
||||||
@ -1682,6 +1685,18 @@ class libiMobileDevice():
|
|||||||
raise libiMobileDeviceException(error_description)
|
raise libiMobileDeviceException(error_description)
|
||||||
|
|
||||||
# ~~~ logging ~~~
|
# ~~~ logging ~~~
|
||||||
|
def _log_diagnostic(self, msg=None):
|
||||||
|
'''
|
||||||
|
Print msg to console
|
||||||
|
'''
|
||||||
|
if not self.verbose:
|
||||||
|
return
|
||||||
|
|
||||||
|
if msg:
|
||||||
|
debug_print(" %s" % msg)
|
||||||
|
else:
|
||||||
|
debug_print()
|
||||||
|
|
||||||
def _log_location(self, *args):
|
def _log_location(self, *args):
|
||||||
'''
|
'''
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user