简体   繁体   中英

How to call one wlst script from another wlst?

I am trying to call one wlst script from another wlst script, by importing the other one. I tried the following:

domain.py

import final

final.foo()

final.py

def foo():
cd('/')

when domain.py calls foo, it fails to recognize CD('/') command as its a wlst specific. i tried importing wlst into final.py but still it didn't work

Finally, i could figure out. In the final.py we need to import wlstModule and pass wls context to function from domain.py. Also in domain.py changed the way foo is imported. Note the way WLS(case important) is used in domain.py

final.py

from wlstModule import *
def foo(wls):
  wls.cd('/')

domain.py

import java.lang.String as jstring
import java.lang.System as jsystem
from final import foo

foo(WLS)

I found another solution to the problem which didn't have the problems the other solution had, but some might say has it's own issues. I used execfile instead of importing the child file. That allowed me to use startEdit, cmo, etc. in the child file, since it is actually run in the parent WLST file at runtime. For me, this is what I am going to do as the child scripts already exist and editing them is not ideal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM