2 Replies Latest reply on Apr 23, 2013 4:33 PM by 1004973

    WLST Libraries

      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 createDomain.py

           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 wl.py 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 createDomain.py as follows:
      set WL_HOME=D:\common\bin\osb1031\wlserver_10.3
      call %WL_HOME%\server\bin\setWLSEnv.cmd
      java weblogic.WLST createDomain.py

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

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

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

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