This discussion is archived
2 Replies Latest reply: Apr 23, 2013 9:33 AM by 1004973 RSS

WLST Libraries

687374 Newbie
Currently Being Moderated
I have a number of WLST scripts which all use a number of common functions I've written such as:
import sys

import os
import shutil
import re

def offline_createManagedServer(Name, Port, ListenAddress):
     create(Name, 'Server')
     set('ListenPort', int(Port))
     set('ListenAddress', ListenAddress)     

This is called by

     readTemplate('D:\\common\\bin\\osb1031' + '/wlserver_10.3/common/templates/domains/wls.jar')
     common.offline_createManagedServer('ManagedServer1', '7001', 'localhost')

I have been attempting to use the instructions at:

Using the above code I get 'NameError: cd' at the first line in offline_createManagedServer -->     cd('/')

I then created the and import that and now get a different error:
Error: No domain or domain template has been read.
Error: set() cannot be applied at this point of path

I want to keep all the common functions in a library style script file so they can be shared.

Has anyone actually got this to work?

I call the as follows:
set WL_HOME=D:\common\bin\osb1031\wlserver_10.3
call %WL_HOME%\server\bin\setWLSEnv.cmd
java weblogic.WLST

Edited by: user10074087 on Dec 13, 2009 10:20 PM
  • 1. Re: WLST Libraries
    687374 Newbie
    Currently Being Moderated
    In case anyone finds this useful, I ended up using:

         jpythonScriptsDir = os.environ.get("SCRIPTS_PYTHON")
         execfile(jpythonScriptsDir + '/common/' + '')

    I run this at the start of all scripts that need access to the common functions.

    execfile loads the definitions in into the namespace that has all of the WLST functions.
  • 2. Re: WLST Libraries
    1004973 Newbie
    Currently Being Moderated
    Four years later and still very useful ... you got me unstuck from having the exact same problem all day, thanks!


  • Correct Answers - 10 points
  • Helpful Answers - 5 points