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


Groups > comp.lang.python > #106341

Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.)

From Ben Finney <ben+python@benfinney.id.au>
Newsgroups comp.lang.python
Subject Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.)
Date 2016-04-03 13:37 +1000
Message-ID <mailman.388.1459654659.28225.python-list@python.org> (permalink)
References <ndq2kn$h77$1@aspen.stu.neva.ru>

Show all headers | View raw


Hongyi Zhao <hongyi.zhao@gmail.com> writes:

> I use the following code to update the os.environ with
> subprocess.Popen

Again, it is quite misleading to describe what you are doing as “update
the os.environ with subprocess.Popen”.

The ‘subprocess.Popen’ call *cannot* upsdate the Python process's
‘os.environ’.

What you're doing is two quite separate steps:

* Obtain a collection of items (key → value pairs).

* Update a dictionary.

Please be clear that's what you're doing because “update ‘os.environ’
with ‘subprocess.Popen’ is *not* that.

> But, I meet the following errors:
>
> ------------
> Traceback (most recent call last):
>   File "/home/werner/software/hpc/dft-to-study/jasp/jasp.git/jasp/bin/
> runjasp.py", line 125, in <module>
>     os.environ.update(line.partition('=')[::2] for line in output.split
> ('\0'))
> AttributeError: 'Popen' object has no attribute 'split'
> -------------------

So your problem is nothing to do with “update ‘os.environ’”. I have
updated the Subject field accordingly.

The problem you're encountering is only to do with ‘subprocess.Popen’.
That should make it much easier to search for the documentation to
understand the problem.

<URL:https://docs.python.org/3/library/subprocess.html#subprocess.Popen.stdout>

-- 
 \     “When people believe that they have absolute knowledge, with no |
  `\     test in reality, this [the Auschwitz crematorium] is how they |
_o__)             behave.” —Jacob Bronowski, _The Ascent of Man_, 1973 |
Ben Finney

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


Thread

Failed to update the os.environ with subprocess.Popen. Hongyi Zhao <hongyi.zhao@gmail.com> - 2016-04-03 03:28 +0000
  Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.) Ben Finney <ben+python@benfinney.id.au> - 2016-04-03 13:37 +1000
    Re: Get the output from a Popen instance (was: Failed to update the os.environ with subprocess.Popen.) Hongyi Zhao <hongyi.zhao@gmail.com> - 2016-04-03 04:00 +0000

csiph-web