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


Groups > comp.lang.python > #106340

Failed to update the os.environ with subprocess.Popen.

From Hongyi Zhao <hongyi.zhao@gmail.com>
Newsgroups comp.lang.python
Subject Failed to update the os.environ with subprocess.Popen.
Date 2016-04-03 03:29 +0000
Organization NPO RUSnet InterNetNews site
Message-ID <ndq2mk$h7a$1@aspen.stu.neva.ru> (permalink)

Show all headers | View raw


Hi all,

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

-------------
from subprocess import Popen

output = Popen("""
/bin/bash <<EOF
source ~/.profile.d/modules/modules.sh
export PATH=$MODULESHOME/../default/bin:$PATH
module add intel/parallel_studio_xe_2015
env -0
EOF
""", shell=True)

if "" in os.environ.data: del os.environ.data[""]
os.environ.clear()
os.environ.update(line.partition('=')[::2] for line in output.split('\0'))
-------------

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'
-------------------

How to solve this issue?
-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.

Back to comp.lang.python | Previous | NextNext 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:29 +0000
  Re: Failed to update the os.environ with subprocess.Popen. Steven D'Aprano <steve@pearwood.info> - 2016-04-03 14:24 +1000
    Re: Failed to update the os.environ with subprocess.Popen. Cameron Simpson <cs@zip.com.au> - 2016-04-03 18:20 +1000
      Re: Failed to update the os.environ with subprocess.Popen. Hongyi Zhao <hongyi.zhao@gmail.com> - 2016-04-03 11:24 +0000
        Re: Failed to update the os.environ with subprocess.Popen. Cameron Simpson <cs@zip.com.au> - 2016-04-04 07:49 +1000

csiph-web