Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #67653

Decoding a process output

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'encoding': 0.05; 'output': 0.05; 'variables': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:process': 0.09; 'runs': 0.10; 'python': 0.11; '2.7': 0.14; "(i'm": 0.16; 'btw': 0.16; 'command,': 0.16; 'lang': 0.16; 'python),': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'variable': 0.18; 'command': 0.22; 'shell': 0.22; 'header:User- Agent:1': 0.23; '(such': 0.24; 'bytes': 0.24; 'parse': 0.24; 'fine': 0.24; 'environment': 0.24; 'question': 0.24; 'header:X -Complaints-To:1': 0.27; 'external': 0.29; 'provided,': 0.31; 'run': 0.32; 'linux': 0.33; 'running': 0.33; 'guess': 0.33; 'case,': 0.35; 'module.': 0.36; 'thanks': 0.36; 'hi,': 0.36; 'should': 0.36; 'application': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'skip:u 10': 0.60; 'new': 0.61; 'relatively': 0.65; 'goal': 0.75
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Francis Moreau <francis.moro@gmail.com>
Subject Decoding a process output
Date Tue, 04 Mar 2014 10:29:43 +0100
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host au213-1-82-235-205-153.fbx.proxad.net
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.7697.1393925404.18130.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1393925404 news.xs4all.nl 2925 [2001:888:2000:d::a6]:47783
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:67653

Show key headers only | View raw


Hi,

In my understanding (I'm relatively new to python), I need to decode any
bytes data provided, in my case, by a shell command (such as findmnt)
started by the subprocess module. The goal of my application is to parse
the command outputs.

My application runs only on linux BTW and should run fine on both python
2.7 and py3k.

My question is when decoding the output bytes data of the external
command, which encoding should I use ?

Should I guess the encoding by inspecting LANG or any LC_* environment
variables ?

Should I force one of those environment variable to a specific value
before running my external command ?

Thanks for any tips.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Decoding a process output Francis Moreau <francis.moro@gmail.com> - 2014-03-04 10:29 +0100

csiph-web