Python Forum

Full Version: How to umount from python script?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, i have the next umount function:

    def umount(self):
        '''unmounts VirtualDVD'''
        cmd = 'gksudo umount VirtualDVD'
        proc = subprocess.Popen(str(cmd), shell=True, stdout=subprocess.PIPE).stdout.read()
        print proc
i get the gksudo and i input my password, but then the umount does nothing.
I keep have mounted the VirtualDVD folder (mounting point)

Why?
How to umount from python?
I want to run the command "gksudo umount VirtualDVD"
try:

cmd = [ 'gksudo', 'umount', 'VirtualDVD' ]
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).stdout.read()
i found it, i must provide the full path to umount.

    def umount(self):
        '''unmounts VirtualDVD'''
        #get virtualdvd folder
        home = QtCore.QDir.homePath()
        vpath = home + "/VirtualDVD"

        cmd = 'gksudo umount ' + vpath
        subprocess.Popen(str(cmd), shell=True, stdout=subprocess.PIPE)