开发者

python/jython NameError

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('/')
   开发者_JAVA百科 ...

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:-)


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜