Search code examples
weblogic11gwlst

Weblogic Scripting Tool common modules


when using WLST, I encounter several problems. We only use Solaris or Linux for our servers, so please remeber this when answering.

1: where should I place common modules for WLST that won't have anything to do with internal WLST-functions(option parsing, logging, output, ...) 1.1: I have written a few of my own, to account for the lack of existing within Jython 2.1 supplied by Oracle.

2: How can I include modules that use WLST internal functions so that they work, and don't lose their information(connect in a module doesn't stay connected when back in the main program).

Greetings


Solution

  • For #1 I am able to include library .py files in the same directory as the target script by adding the current path to sys.path. For instance, if I have a file functions.py, I would use this code:

    import os, sys
    sys.path.append(os.path.dirname(os.path.abspath(inspect.getsourcefile(lambda:(True)))))
    import functions
    

    I'm not sure if adding to sys.path is the Pythonic way of doing things, but it gets the job done and WLST is pretty "Wild West" as well.

    If you're stuck using an older version of Weblogic like 10.x (and possibly 11g?), that embeds Python 2.1, you'll find that it doesn't have many now-standard libraries including the inspect library. You'll have to use sys.argv[0] instead of os.path.abspath(inspect.getsourcefile(lambda:(True))).