[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

using subprocess.Popen env parameter

enda man

3/3/2010 5:06:00 PM

Hi,

I want to use the env parameter to subprocess.Popen to pass in a path
to a location the process needs to run,
I do have a env variable already called MS_VC_PATH and I want to add
to it, not set up more in the PATH variable.

/////
ms_vc_path=os.environ['MS_VC_PATH']
cl_path = ms_vc_path + '\VC\bin'
lib_vc_path = ms_vc_path + '\VC\lib'
myenv = os.environ
myenv["PATH"] = cl_path + ";" + lib_vc_path + ";" + myenv["PATH"]

subprocess.Popen("midl /D \"_DEBUG\" /nologo /char signed /env win32 /
Oicf /tlb \"ActivexPlugin.tlb\" /h \"ActivexPlugin_i.h\" /iid
\"ActivexPlugin_i.c\" /proxy \"ActivexPlugin_p.c\" /error stub_data
ActivexPlugin.idl", env=myenv)

///

but it seems that midl can not see the new path I am sending to it
using the env variable, am I using env correctly?

here is my output:
midl : command line error MIDL1005 : cannot find C preprocessor cl.exe

Any help?
EM
1 Answer

John Doe

3/5/2010 12:10:00 AM

0

On Wed, 03 Mar 2010 09:05:47 -0800, enda man wrote:

> cl_path = ms_vc_path + '\VC\bin'

The backslash is used as an escape character within string literals.
Either use raw strings:

cl_path = ms_vc_path + r'\VC\bin'

or escape the backslashes:

cl_path = ms_vc_path + '\\VC\\bin'

or use os.path.join():

cl_path = os.path.join(ms_vc_path, 'VC', 'bin')