From c741ec7035437bc2d5c14609d1c9809d1859620e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 22 Mar 2025 07:25:15 +0530 Subject: [PATCH] Cleanup previous PR --- src/calibre/devices/udisks.py | 13 +++++-------- src/calibre/devices/usbms/device.py | 7 ++++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/calibre/devices/udisks.py b/src/calibre/devices/udisks.py index aadd031f54..85150bc4e0 100644 --- a/src/calibre/devices/udisks.py +++ b/src/calibre/devices/udisks.py @@ -10,6 +10,7 @@ import os import re import subprocess from contextlib import suppress + from calibre.constants import isfreebsd @@ -91,14 +92,6 @@ class UDisks: def find_device_vols_by_serial(self, serial): from jeepney import DBusAddress, new_method_call - - def decodePath(encoded): - ret = '' - for c in encoded: - if (c != 0): - ret += str(c) - return ret - drives = [] blocks = [] vols = [] @@ -182,6 +175,7 @@ class UDisks: },)) self.send(msg) + def get_udisks(): return UDisks() @@ -200,14 +194,17 @@ def umount(node_path): with get_udisks() as u: u.unmount(node_path) + def rescan(node_path): with get_udisks() as u: u.rescan(node_path) + def find_device_vols_by_serial(serial): with get_udisks() as u: return u.find_device_vols_by_serial(serial) + def test_udisks(): import sys dev = sys.argv[1] diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index ee61182b5c..da255521d5 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -20,7 +20,7 @@ from contextlib import suppress from itertools import repeat from calibre import prints -from calibre.constants import DEBUG, is_debugging, isfreebsd, islinux, ismacos, iswindows +from calibre.constants import is_debugging, isfreebsd, islinux, ismacos, iswindows from calibre.devices.errors import DeviceError from calibre.devices.interface import FAKE_DEVICE_SERIAL, DevicePlugin, ModelMetadata from calibre.devices.usbms.deviceconfig import DeviceConfig @@ -737,7 +737,7 @@ class Device(DeviceConfig, DevicePlugin): try: mp = mount(node) break - except Exception as e: + except Exception: if i < 5: rescan(node) time.sleep(1) @@ -758,7 +758,7 @@ class Device(DeviceConfig, DevicePlugin): for vol in vols: try: mp = fmount(vol['Device']) - except Exception as e: + except Exception: print('Failed to mount: ' + vol['Device']) import traceback traceback.print_exc() @@ -768,6 +768,7 @@ class Device(DeviceConfig, DevicePlugin): # Mount Point becomes Mount Path mp += '/' + DEBUG = is_debugging() if DEBUG: print('FBSD:\tmounted', vol['Device'], 'on', mp) if mtd == 0: