Linux: Support systems that have udisks2 but not udisks1

This commit is contained in:
Kovid Goyal 2012-07-03 13:15:27 +05:30
parent 1b491493b6
commit 43ad7fb0ba

View File

@ -159,16 +159,29 @@ def get_udisks(ver=None):
return u
return UDisks2() if ver == 2 else UDisks()
def mount(node_path):
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):
u = get_udisks1()
u.mount(node_path)
def eject(node_path):
u = UDisks()
u = get_udisks1()
u.eject(node_path)
def umount(node_path):
u = UDisks()
u = get_udisks1()
u.unmount(node_path)
def test_udisks(ver=None):