0

im facing typical NameError (without any additional message) on command "cd" while importing other file.

E.g. executor.py

import sys
from java.lang import System
import ds_update

x = ds_update.DataSource()
x.someAction()

And ds_update.py import sys from java.lang import System

import sys
from java.lang import System

class DataSource:

  def someAction(self): 
    try:
      cd('/')
    ...

Got error: (if those commands are in one file, there is no problem with cd)

Problem invoking WLST - Traceback (innermost last):
  File "...\executor.py", line 17, in ?
  File "...\ds_update.py", line 11, in updateDS
NameError: cd

Thank you:-)

7
  • You're trying to call a function that doesn't exist, namely cd(), i think the function you're looking for is os.chdir() Commented Aug 5, 2011 at 10:31
  • I think that problem is that im calling WLST (weblogic scripting tool) via Jython (almost python) and this one has its own set of methods including cd. because if this is in one file, it works with cd. What im invoking is java weblogic.WLST executor.py Commented Aug 5, 2011 at 10:36
  • I never used Jython nor WLST, but you have to import these methods in your script to be able to use them. Commented Aug 5, 2011 at 10:46
  • it seems that this tool adds some custom imports to passed script and that's why I don't know cd. It seems I will have to all use it in one file unless i find out which imports are used Commented Aug 5, 2011 at 10:47
  • 1
    @MatToufoutu Why don't you post your comments as an answer? Commented Aug 5, 2011 at 10:57

3 Answers 3

3

You're trying to use a function that isn't defined, namely cd(), according to your comments, it is something provided by WLST. I never used Jython nor WLST, but you have to find a way to import these methods in your script to be able to use them.

Sign up to request clarification or add additional context in comments.

Comments

2

there are a few imports needed, namely at least:

import wl

the way to generate the wl module is described by Oracle here http://docs.oracle.com/cd/E15051_01/wls/docs103/config_scripting/using_WLST.html#wp1094333

then you should prefix with "wl." all your "cd" and other WLST built-in commands.

you will find more here

http://www.javamonamour.org/2013/08/wlst-nameerror-cd.html

1 Comment

Note that link-only answers are discouraged, SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference.
0

Even though it is old, I want to add this:

WLST uses a type of namespace. because of this, functions pertaining to wlst don't work if you put the to-be-imported-files not in /wlserver_10.3/common/wlst

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.