[prev in list] [next in list] [prev in thread] [next in thread]
List: python-list
Subject: Re: How to execute "gksudo umount VirtualDVD"
From: Demosthenes Koptsis <demosthenesk () gmail ! com>
Date: 2016-10-29 4:56:54
Message-ID: 7cfe5337-c021-9f23-545c-d33d40b4f418 () gmail ! com
[Download RAW message or body]
The code is ok, i need to provide the absolute 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)
This is strange, in terminal "gksudo umount VirtualDVD" worked fine but
not from code...
From code i have to "gksudo umount /home/user/VirtualDVD"
Thanks all for your help.
Regards,
Dim
On 10/29/2016 01:22 AM, Wildman via Python-list wrote:
> On Fri, 28 Oct 2016 17:19:17 -0500, Wildman wrote:
>
>> On Fri, 28 Oct 2016 11:05:17 +0300, Demosthenes Koptsis wrote:
>>
>>> Yes it was pasted wrong...
>>>
>>> def umount(self):
>>> '''unmounts VirtualDVD'''
>>> cmd = 'gksudo umount VirtualDVD'
>>> proc = subprocess.Popen(str(cmd), shell=True,
>>> stdout=subprocess.PIPE).stdout.read()
>>> print proc
>>>
>>> it fails silently.... the gksudo runs correctly. I can input the password.
>>>
>>> But the umount does nothing. I keep have mounted the VirtualDVD folder.
>>>
>>>
>>> On 10/28/2016 12:54 AM, Ian Kelly wrote:
>>>> On Thu, Oct 27, 2016 at 3:30 PM, Demosthenes Koptsis
>>>> <demosthenesk@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
>> Try this:
>>
>> def umount(self):
>> '''unmounts VirtualDVD'''
>> cmd = ["gksudo", "umount", VirtualDVD]
> ^
>
>
>> p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
>> proc = p.communicate()
>> print proc
> Oops!
>
--
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic