Re: [Tutor] Issue in using "subprocess.Popen" for parsing the command output

2018-11-26 Thread Mats Wichmann
On 11/25/18 10:58 AM, srinivasan wrote: > Even only with "*proc.decode("utf-8")"* in the above code still it seems to > throw the error > > #return proc.strip().decode("utf-8") > #return proc.decode("utf-8").strip() > *return proc.decode("utf-8")* > > Error: > /home/srinivasan/Downloa

Re: Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Chris Angelico
On Mon, Nov 26, 2018 at 5:40 AM srinivasan wrote: > > Dear Karsten, > > With the help of Mrab Inputs, I tried Even with "return > stdout.strip().decode("utf-8")", it still seems to be an issue, I am using > python 3.6, is this causing a issue? No, it isn't. Two things are causing most of your is

Re: Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Dear Karsten, With the help of Mrab Inputs, I tried Even with "return stdout.strip().decode("utf-8")", it still seems to be an issue, I am using python 3.6, is this causing a issue? /home/srinivasan/Downloads/wifidisconnectissuenov23_homework/venv/bin/python /home/srinivasan/Downloads/wifidiscon

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Dear Mrab, Even with "return stdout.strip().decode("utf-8")", it still seems to be an issue, I am using python 3.6, is this causing a issue? /home/srinivasan/Downloads/wifidisconnectissuenov23_homework/venv/bin/python /home/srinivasan/Downloads/wifidisconnectissuenov23_homework/qa/test_library/t

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Thanks a lot for your quick responses Mrab and appreciate the same. I changed the snippet as below, still it seems to be an issue, I am using python3 version: def main(ssid, pw): try: cmd = "nmcli device wifi connect '%s' password '%s'" % (ssid, pw) proc = subprocess.Popen(

Aw: Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Karsten Hilbert
> Even only with "*proc.decode("utf-8")"* in the above code still it seems to > throw the error No it does not. It throws the same TYPE of error due to the same SORT of mistake you made. You need to read carefully and try to think about what you read. Karsten -- https://mail.python.org/mailman/

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread MRAB
On 2018-11-25 17:54, srinivasan wrote: Hope now I have changed on the string output as below, could you please correct me if am still wrong? import sys import subprocess interface = "wlan0" def main(ssid, pw):     try:         cmd = "nmcli device wifi connect '%s' password '%s'" % (ssid, pw

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Even only with "*proc.decode("utf-8")"* in the above code still it seems to throw the error #return proc.strip().decode("utf-8") #return proc.decode("utf-8").strip() *return proc.decode("utf-8")* Error: /home/srinivasan/Downloads/wifidisconnectissuenov23_homework/venv/bin/python /home

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Hope now I have changed on the string output as below, could you please correct me if am still wrong? import sys import subprocess interface = "wlan0" def main(ssid, pw): try: cmd = "nmcli device wifi connect '%s' password '%s'" % (ssid, pw) proc = subprocess.Popen(cmd, st

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread MRAB
On 2018-11-25 17:13, srinivasan wrote: Dear Python Experts Team, As am newbie still learning the python syntax from past 2 weeks, Excuse me, If this might be silly question, As I am trying to execute shell command (ie, nmcli) using "subprocess.Popen". 1. Am trying to improve the below code with

Aw: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Karsten Hilbert
> Kindly do the needful as am stuck with this issue from 2 days How about YOU do the needful and post code that can actually be tested. Karsten -- https://mail.python.org/mailman/listinfo/python-list

Re: Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread Wildman via Python-list
On Sun, 25 Nov 2018 22:43:10 +0530, srinivasan wrote: > Dear Python Experts Team, > > As am newbie still learning the python syntax from past 2 weeks, Excuse me, > If this might be silly question, As I am trying to execute shell command > (ie, nmcli) using "subprocess.Popen". > > *return pro

Issue in using "subprocess.Popen" for parsing the command output

2018-11-25 Thread srinivasan
Dear Python Experts Team, As am newbie still learning the python syntax from past 2 weeks, Excuse me, If this might be silly question, As I am trying to execute shell command (ie, nmcli) using "subprocess.Popen". 1. Am trying to improve the below code with "try" and "exception", could you please