How to execute "gksudo umount VirtualDVD"

Ian Kelly ian.g.kelly at gmail.com
Thu Oct 27 17:54:59 EDT 2016


On Thu, Oct 27, 2016 at 3:30 PM, Demosthenes Koptsis
<demosthenesk at gmail.com> wrote:
> I want to execute the command "gksudo umount VirtualDVD"
>
> My code is this but it fails:
>
> def umount(self):
>     '''unmounts VirtualDVD''' cmd ='gksudo umount VirtualDVD' proc =
> subprocess.Popen(str(cmd),shell=True,stdout=subprocess.PIPE).stdout.read()
>     print proc

It looks like your code pasted incorrectly.

> It pops up the gksudo dialog, and then fails. But i don't get any stdout or
> stderror.

Fails how? Is there an error? Does it hang? Does nothing happen at all?

My initial thought is that you might want to try using
Popen.communicate instead of stdout.read in case you're getting
deadlocked. See the big red warning below
https://docs.python.org/3/library/subprocess.html#subprocess.Popen.stdout



More information about the Python-list mailing list