mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Finish up the UDisks2 support, however for the moment we continue to use UDisks1 as who knows what state UDisks2 is in all the distros out there
This commit is contained in:
parent
dc2fc23d3c
commit
8156e13e83
@ -5,10 +5,6 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
# First repeat after me: Linux desktop infrastructure is designed by a
|
|
||||||
# committee of rabid monkeys on crack. They would not know a decent desktop if
|
|
||||||
# it was driving the rabid monkey extermination truck that runs them over.
|
|
||||||
|
|
||||||
import os, dbus, re
|
import os, dbus, re
|
||||||
|
|
||||||
def node_mountpoint(node):
|
def node_mountpoint(node):
|
||||||
@ -67,6 +63,7 @@ class UDisks2(object):
|
|||||||
|
|
||||||
BLOCK = 'org.freedesktop.UDisks2.Block'
|
BLOCK = 'org.freedesktop.UDisks2.Block'
|
||||||
FILESYSTEM = 'org.freedesktop.UDisks2.Filesystem'
|
FILESYSTEM = 'org.freedesktop.UDisks2.Filesystem'
|
||||||
|
DRIVE = 'org.freedesktop.UDisks2.Drive'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.bus = dbus.SystemBus()
|
self.bus = dbus.SystemBus()
|
||||||
@ -131,6 +128,21 @@ class UDisks2(object):
|
|||||||
raise
|
raise
|
||||||
return mp
|
return mp
|
||||||
|
|
||||||
|
def unmount(self, device_node_path):
|
||||||
|
d = self.device(device_node_path)
|
||||||
|
d.Unmount({'force':True, 'auth.no_user_interaction':True},
|
||||||
|
dbus_interface=self.FILESYSTEM)
|
||||||
|
|
||||||
|
def drive_for_device(self, device):
|
||||||
|
drive = device.Get(self.BLOCK, 'Drive',
|
||||||
|
dbus_interface='org.freedesktop.DBus.Properties')
|
||||||
|
return self.bus.get_object('org.freedesktop.UDisks2', drive)
|
||||||
|
|
||||||
|
def eject(self, device_node_path):
|
||||||
|
drive = self.drive_for_device(self.device(device_node_path))
|
||||||
|
drive.Eject({'auth.no_user_interaction':True},
|
||||||
|
dbus_interface=self.DRIVE)
|
||||||
|
|
||||||
def get_udisks(ver=None):
|
def get_udisks(ver=None):
|
||||||
if ver is None:
|
if ver is None:
|
||||||
try:
|
try:
|
||||||
@ -140,7 +152,6 @@ def get_udisks(ver=None):
|
|||||||
return u
|
return u
|
||||||
return UDisks2() if ver == 2 else UDisks()
|
return UDisks2() if ver == 2 else UDisks()
|
||||||
|
|
||||||
|
|
||||||
def mount(node_path):
|
def mount(node_path):
|
||||||
u = UDisks()
|
u = UDisks()
|
||||||
u.mount(node_path)
|
u.mount(node_path)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user