【问题标题】:Disable GNOME's automount with Python使用 Python 禁用 GNOME 的自动挂载
【发布时间】:2009-06-22 11:27:13
【问题描述】:

我需要阻止 GNOME/Nautilus 在系统出现时自动挂载新设备和分区。我怎样才能在 python 中完成这个?

【问题讨论】:

    标签: python gnome hal automount


    【解决方案1】:

    为什么要用 Python 来做呢?您可以只使用命令行,如下所示:

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

    如果你真的需要它在 Python 中,那么你可以使用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)
    

    但我真的不确定这里是否有必要。

    【讨论】:

    猜你喜欢
    • 2011-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多