mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Cleanup previous PR
This commit is contained in:
parent
081c039ecc
commit
c741ec7035
@ -10,6 +10,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
|
||||||
from calibre.constants import isfreebsd
|
from calibre.constants import isfreebsd
|
||||||
|
|
||||||
|
|
||||||
@ -91,14 +92,6 @@ class UDisks:
|
|||||||
|
|
||||||
def find_device_vols_by_serial(self, serial):
|
def find_device_vols_by_serial(self, serial):
|
||||||
from jeepney import DBusAddress, new_method_call
|
from jeepney import DBusAddress, new_method_call
|
||||||
|
|
||||||
def decodePath(encoded):
|
|
||||||
ret = ''
|
|
||||||
for c in encoded:
|
|
||||||
if (c != 0):
|
|
||||||
ret += str(c)
|
|
||||||
return ret
|
|
||||||
|
|
||||||
drives = []
|
drives = []
|
||||||
blocks = []
|
blocks = []
|
||||||
vols = []
|
vols = []
|
||||||
@ -182,6 +175,7 @@ class UDisks:
|
|||||||
},))
|
},))
|
||||||
self.send(msg)
|
self.send(msg)
|
||||||
|
|
||||||
|
|
||||||
def get_udisks():
|
def get_udisks():
|
||||||
return UDisks()
|
return UDisks()
|
||||||
|
|
||||||
@ -200,14 +194,17 @@ def umount(node_path):
|
|||||||
with get_udisks() as u:
|
with get_udisks() as u:
|
||||||
u.unmount(node_path)
|
u.unmount(node_path)
|
||||||
|
|
||||||
|
|
||||||
def rescan(node_path):
|
def rescan(node_path):
|
||||||
with get_udisks() as u:
|
with get_udisks() as u:
|
||||||
u.rescan(node_path)
|
u.rescan(node_path)
|
||||||
|
|
||||||
|
|
||||||
def find_device_vols_by_serial(serial):
|
def find_device_vols_by_serial(serial):
|
||||||
with get_udisks() as u:
|
with get_udisks() as u:
|
||||||
return u.find_device_vols_by_serial(serial)
|
return u.find_device_vols_by_serial(serial)
|
||||||
|
|
||||||
|
|
||||||
def test_udisks():
|
def test_udisks():
|
||||||
import sys
|
import sys
|
||||||
dev = sys.argv[1]
|
dev = sys.argv[1]
|
||||||
|
@ -20,7 +20,7 @@ from contextlib import suppress
|
|||||||
from itertools import repeat
|
from itertools import repeat
|
||||||
|
|
||||||
from calibre import prints
|
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.errors import DeviceError
|
||||||
from calibre.devices.interface import FAKE_DEVICE_SERIAL, DevicePlugin, ModelMetadata
|
from calibre.devices.interface import FAKE_DEVICE_SERIAL, DevicePlugin, ModelMetadata
|
||||||
from calibre.devices.usbms.deviceconfig import DeviceConfig
|
from calibre.devices.usbms.deviceconfig import DeviceConfig
|
||||||
@ -737,7 +737,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
try:
|
try:
|
||||||
mp = mount(node)
|
mp = mount(node)
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception:
|
||||||
if i < 5:
|
if i < 5:
|
||||||
rescan(node)
|
rescan(node)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -758,7 +758,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
for vol in vols:
|
for vol in vols:
|
||||||
try:
|
try:
|
||||||
mp = fmount(vol['Device'])
|
mp = fmount(vol['Device'])
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print('Failed to mount: ' + vol['Device'])
|
print('Failed to mount: ' + vol['Device'])
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
@ -768,6 +768,7 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
|
|
||||||
# Mount Point becomes Mount Path
|
# Mount Point becomes Mount Path
|
||||||
mp += '/'
|
mp += '/'
|
||||||
|
DEBUG = is_debugging()
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
print('FBSD:\tmounted', vol['Device'], 'on', mp)
|
print('FBSD:\tmounted', vol['Device'], 'on', mp)
|
||||||
if mtd == 0:
|
if mtd == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user