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

2018-11-27 Thread srinivasan
Dear All, I have fixed the issue with below code snippet for parsing the command output without try and exception, pls let me know if any improvements are needed, might be useful for others def to_bytes(self, str): # Encode to UTF-8 to get binary data. if isinstance(str,

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

2018-11-25 Thread Cameron Simpson
On 26Nov2018 09:03, Steven D'Aprano wrote: On Sun, Nov 25, 2018 at 10:43:10PM +0530, srinivasan wrote: 1. Am trying to improve the below code with "try" and "exception", could you please help me how "try" and "exception" can be used on the below code snippet. I hope in my code with try and

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

2018-11-25 Thread Steven D'Aprano
I think you are sending email using Gmail. If so, there is a command in Gmail to send only PLAIN TEXT with no added formatting. Please use it. Your code at the moment has extra asterisks * added at the beginning and end of each line. More comments below. On Sun, Nov 25, 2018 at 10:43:10PM

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

2018-11-25 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: >

Re: [Tutor] 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

[Tutor] 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