views:

330

answers:

1

Hi,

I need to stop GNOME/Nautilus from automagically mounting new devices and partitions as they appear to the system. How can I accomplish this in python?

+3  A: 

Why would do it in Python? You can just use the commandline, as in:

gconftool-2 --type bool --set /apps/nautilus/preferences/media_automount false

If you really need it to be in Python, then you can use the subprocess module:

import subprocess

def setAutomount(value):
    """
    @type value: boolean
    """
    cmd = ['gconftool-2', '--type', 'bool', '--set', 
            '/apps/nautilus/preferences/media_automount']
    cmd.append(str(value).lower())
    subprocess.check_call(cmd)

setAutomount(False)

But I'm really not sure that it's necessary here.

NicDumZ
You could do something equivalent with the 'gconf' python module, which wraps libgconf, documented here: http://library.gnome.org/devel/gconf/stable/
Glyph