mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
DRYer
This commit is contained in:
parent
04ad7bc901
commit
508f957b05
@ -31,6 +31,10 @@ class NoUDisks1(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def basic_mount_options():
|
||||||
|
return ['rw', 'noexec', 'nosuid', 'nodev', 'uid=%d'%os.geteuid(), 'gid=%d'%os.getegid()]
|
||||||
|
|
||||||
|
|
||||||
class UDisks(object):
|
class UDisks(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -54,8 +58,7 @@ class UDisks(object):
|
|||||||
d = self.device(device_node_path)
|
d = self.device(device_node_path)
|
||||||
try:
|
try:
|
||||||
return unicode_type(d.FilesystemMount('',
|
return unicode_type(d.FilesystemMount('',
|
||||||
['auth_no_user_interaction', 'rw', 'noexec', 'nosuid',
|
['auth_no_user_interaction'] + basic_mount_options()))
|
||||||
'nodev', 'uid=%d'%os.geteuid(), 'gid=%d'%os.getegid()]))
|
|
||||||
except Exception:
|
except Exception:
|
||||||
# May be already mounted, check
|
# May be already mounted, check
|
||||||
mp = node_mountpoint(unicode_type(device_node_path))
|
mp = node_mountpoint(unicode_type(device_node_path))
|
||||||
@ -133,13 +136,11 @@ class UDisks2(object):
|
|||||||
|
|
||||||
def mount(self, device_node_path):
|
def mount(self, device_node_path):
|
||||||
d = self.device(device_node_path)
|
d = self.device(device_node_path)
|
||||||
mount_options = ['rw', 'noexec', 'nosuid',
|
|
||||||
'nodev', 'uid=%d'%os.geteuid(), 'gid=%d'%os.getegid()]
|
|
||||||
try:
|
try:
|
||||||
return as_unicode(d.Mount(
|
return as_unicode(d.Mount(
|
||||||
{
|
{
|
||||||
'auth.no_user_interaction':True,
|
'auth.no_user_interaction':True,
|
||||||
'options':','.join(mount_options)
|
'options':','.join(basic_mount_options())
|
||||||
},
|
},
|
||||||
dbus_interface=self.FILESYSTEM))
|
dbus_interface=self.FILESYSTEM))
|
||||||
except Exception:
|
except Exception:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user