Thursday, October 31, 2013

WLST: expand the PYTHONPATH

Official doc here: http://docs.python.org/2/tutorial/modules.html#the-module-search-path
I run this test:

/opt/oracle/fmw11_1_1_5/osb/common/bin/wlst.sh

wls:/offline> print sys.path


['/opt/oracle/fmw11_1_1_5/wlserver_10.3/server/lib/weblogic.jar/Lib'
 '__classpath__'
 '/opt/oracle/fmw11_1_1_5/wlserver_10.3/server/lib/weblogic.jar'
 '/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/modules/jython-modules.jar/Lib'
 '/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst'
 '/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/lib'
 '/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/modules'
 '/opt/oracle/fmw11_1_1_5/oracle_common/common/wlst'
 '/opt/oracle/fmw11_1_1_5/oracle_common/common/wlst/lib'
 '/opt/oracle/fmw11_1_1_5/oracle_common/common/wlst/modules'
 '/opt/oracle/fmw11_1_1_5/oracle_common/common/script_handlers'
 '/opt/oracle/fmw11_1_1_5/osb/common/wlst'
 '/opt/oracle/fmw11_1_1_5/osb/common/wlst/lib'
 '/opt/oracle/fmw11_1_1_5/osb/common/wlst/modules'
 '.']




not all those folder/files actually exist by default:

/opt/oracle/fmw11_1_1_5/oracle_common/common/wlst/modules , /opt/oracle/fmw11_1_1_5/osb/common/wlst/modules

don't exist...
but
/opt/oracle/fmw11_1_1_5/wlserver_10.3/common/wlst/modules
exists, and that's where I would put my own modules.
However, you can RUNTIME add modules. I put a module cmdb.py in /opt/oracle/usr. It contains a function "getwhoami":
sys.path.append('/opt/oracle/usr')
wls:/offline> from cmdb import getwhoami
wls:/offline> print getwhoami()
soa


No comments: