Question about envvars
rceci at adams.com
rceci at adams.com
Mon Jun 7 10:34:31 EDT 1999
swig 1.1p5
Python 1.5.1
SGI-Irix 6.5/MIPspro 7.2.1
Hello,
I have built a shared module that reads flat files for environment
variable information, and makes subsequent putenv calls for those
pertinent ones. This functionality is encapsulated in a c++ class,
FileRegistry, which I think I have working correctly, using shadow
classes under python. All I expose in the class is the ctor, the dtor,
and the method called exportEnvVars():
%module MDIreg
%{
#include "fileregistry.h"
%}
class FileRegistry
{
public:
FileRegistry(bool, bool);
~FileRegistry();
void exportEnvVars();
};
...
However, I can't seem to get the envvars to persist into the current
process space. If I fork off a child, then I can see the envvars that I
expect. Here is a pretty explanatory log:
[rceci_latest]{rcecil}/vobs/srg/src/registry> python
Python 1.5.1 (#3, May 21 1999, 16:24:24) [C] on irix646-32-mips2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> import MDIreg
>>> m = MDIreg.FileRegistry(1,1)
>>> m.exportEnvVars()
>>> os.system("env | grep MDI_REG_VERSION")
MDI_REG_VERSION=10.0
0
>>> os.environ['MDI_REG_VERSION']
Traceback (innermost last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python1.5/UserDict.py", line 12, in __getitem__
def __getitem__(self, key): return self.data[key]
KeyError: MDI_REG_VERSION
>>> os.environ.keys()
['WINEDITOR', 'TS', 'MAIL', 'NOMSGLABEL', 'PWD', 'MU',
'MDI_PRINT_UCO_SIZ', 'topdir', 'MDI_ACAR_SITE', 'VOB_ROOT', 'QTDIR',
'LM_LICE
NSE_FILE', 'NPX_PLUGIN_PATH', 'PRINTER', 'HOST', 'PYTHONPATH',
'CLASSPATH', 'MOZILLA_HOME', 'REMOTEUSER', 'NOMSGSEVERITY', 'LIB_TOOL
S', 'CVSROOT', 'SHELL', 'TCLLIBPATH', 'LIB_VAR', 'MANPATH', 'EDITOR',
'CLEARCASE_BLD_UMASK', 'HZ', 'HOME', 'CLEARCASE_ROOT', 'SHLVL'
, 'LIBRARY_PATH', 'TZ', 'BUILDMEISTER', 'TERM', 'LANG', 'VOB_TOP',
'LD_LIBRARY_PATH', 'MSGVERB', 'MAGIC_PATH', 'CVINSTRLIB', 'PATH',
'T', 'USER', 'LOGNAME', 'CPLUS_INCLUDE_PATH', 'SCRIPTS_DIR',
'HOSTTYPE', 'REMOTEHOST', 'BL', 'CLEARCASE_CMDLINE', 'LIB_ARCH']
>>>
>>> os.system("/usr/local/bin/python")
Python 1.5.1 (#3, May 21 1999, 16:24:24) [C] on irix646-32-mips2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import os
>>> os.environ['MDI_REG_VERSION']
'10.0'
>>> ^D
0
>>> ^D
---
As you can see I can fork of either a simple csh command, or a
completely new python interpreter, and either way, the children can see
the result of the exportEnvVars() method call. By the way, when I
build my module in debug mode, I can see my "destroyed" messages I
specifically coded in the dtor of the class, to verify that my
FileRegistry object is being destroyed when I expect it.
Any ideas or suggestions?
Thanks
Rob Cecil
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
More information about the Python-list
mailing list