Re: Py3: decode subprocess output

2010-11-03 Thread Gnarlodious
OK, it turns out I had to tweak the parsing minimally for Python3: 1) Substrings such as st[5] no longer work (returns an ascii number), instead st[5:6] selects one character 2) Replacements need to specified as bytes: s.replace('R','*') change to s.replace(b'R',b'*') So I think this problem is

Re: Py3: decode subprocess output

2010-11-03 Thread Tim Harig
On 2010-11-03, Gnarlodious wrote: > Under Python 3, subprocess.check_output returns a bytestring that > doesn't parse. Since the CLI program (written in the 1990's) will > never send Unicode, is there a way to downconvert the bytestring into > type str so as to emulate Py2.6 behavior? str() will

Re: Py3: decode subprocess output

2010-11-03 Thread Martin v. Loewis
> Under Python 3, subprocess.check_output returns a bytestring that > doesn't parse. Since the CLI program (written in the 1990's) will > never send Unicode, is there a way to downconvert the bytestring into > type str so as to emulate Py2.6 behavior? What do you mean by "that doesn't parse"? Retu

Py3: decode subprocess output

2010-11-02 Thread Gnarlodious
Under Python 2.6, commands.getoutput returns text type str containing ANSI Terminal formatting hex characters: "\x1b[1;31mSun : \x1b[1;36m114.902\x1b[0m - 0\xf800' (-)\x1b[1;33m I have a system for parsing out the relevant parts and I prefer to keep using that system. Under Python 3, subproces