Skip to content

Commit

Permalink
more print...
Browse files Browse the repository at this point in the history
  • Loading branch information
xxyzz committed Nov 30, 2023
1 parent 8117f73 commit 4d36fae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions send_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,14 @@ def send_files(self, job: Any) -> None:

# https://github.com/kovidgoyal/calibre/blob/320fb96bbd08b99afbf3de560f7950367d21c093/src/calibre/gui2/device.py#L1772
has_book, *_, paths = self.gui.book_on_device(self.job_data.book_id)
print(f"{has_book=} {paths=}", flush=True)
if has_book and job is not None and self.job_data.book_fmt != "EPUB":
self.move_files_to_kindle(self.gui.device_manager.device, Path(paths.pop()))
library_book_path = Path(self.job_data.book_path)
if library_book_path.stem.endswith("_en"):
library_book_path.unlink()
self.gui.status_bar.show_message(self.notif)
else:
elif job is None:
# upload book and cover to device
self.gui.update_thumbnail(self.job_data.mi)
# without this the book language won't be English after uploading
Expand All @@ -101,6 +102,7 @@ def send_files(self, job: Any) -> None:

def move_files_to_kindle(self, device_driver: Any, device_book_path: Path) -> None:
use_mtp = is_mtp_device(device_driver)
print(f"{use_mtp=}", flush=True)
if not use_mtp:
# _main_prefix: Kindle mount point, /Volumes/Kindle
device_mount_point = Path(device_driver._main_prefix)
Expand All @@ -117,11 +119,11 @@ def move_files_to_kindle(self, device_driver: Any, device_book_path: Path) -> No
sidecar_folder = device_book_path.parent.joinpath(
f"{device_book_path.stem}.sdr"
)
print(f"{sidecar_folder=}")
print(f"{sidecar_folder=}", flush=True)
if use_mtp:
for file_path in (self.ll_path, self.x_ray_path):
dest_path = sidecar_folder.joinpath(file_path.name)
print(f"{dest_path=}")
print(f"{dest_path=}", flush=True)
upload_file_to_kindle_mtp(device_driver, file_path, dest_path)
else:
sidecar_folder = device_mount_point.joinpath(sidecar_folder)
Expand Down Expand Up @@ -202,6 +204,7 @@ def device_connected(gui: Any, book_fmt: str) -> str | bool:
def is_mtp_device(device_driver: Any) -> bool:
# https://github.com/kovidgoyal/calibre/blob/475b0d3d2e6678dc4fd5441619f71a048c3806ea/src/calibre/devices/mtp/driver.py#L49
if hasattr(device_driver, "DEVICE_PLUGBOARD_NAME"):
print(f"{device_driver.DEVICE_PLUGBOARD_NAME=}", flush=True)
return device_driver.DEVICE_PLUGBOARD_NAME == "MTP_DEVICE"
return False

Expand Down

0 comments on commit 4d36fae

Please sign in to comment.