mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Linux: Support systems that have udisks2 but not udisks1
This commit is contained in:
parent
1b491493b6
commit
43ad7fb0ba
@ -159,16 +159,29 @@ def get_udisks(ver=None):
|
|||||||
return u
|
return u
|
||||||
return UDisks2() if ver == 2 else UDisks()
|
return UDisks2() if ver == 2 else UDisks()
|
||||||
|
|
||||||
|
def get_udisks1():
|
||||||
|
u = None
|
||||||
|
try:
|
||||||
|
u = UDisks()
|
||||||
|
except NoUDisks1:
|
||||||
|
try:
|
||||||
|
u = UDisks2()
|
||||||
|
except NoUDisks2:
|
||||||
|
pass
|
||||||
|
if u is None:
|
||||||
|
raise EnvironmentError('UDisks not available on your system')
|
||||||
|
return u
|
||||||
|
|
||||||
def mount(node_path):
|
def mount(node_path):
|
||||||
u = UDisks()
|
u = get_udisks1()
|
||||||
u.mount(node_path)
|
u.mount(node_path)
|
||||||
|
|
||||||
def eject(node_path):
|
def eject(node_path):
|
||||||
u = UDisks()
|
u = get_udisks1()
|
||||||
u.eject(node_path)
|
u.eject(node_path)
|
||||||
|
|
||||||
def umount(node_path):
|
def umount(node_path):
|
||||||
u = UDisks()
|
u = get_udisks1()
|
||||||
u.unmount(node_path)
|
u.unmount(node_path)
|
||||||
|
|
||||||
def test_udisks(ver=None):
|
def test_udisks(ver=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user