模块化 python 脚本中的 Weblogic WSLT
Weblogic WSLT in modular python script
我正在创建一个脚本,以使用 wslt.sh
以声明方式自动创建 JMS 资源。这样我只需要 运行 wslt.sh create_resources.py planned_resources.properties
create_resources.py 导入了我的另一个模块 import include.jms as nmjms
。此 include/jms.py 调用 WSLT 的 cd
和 cmo
。
问题是,调用cd
不会改变jms.py模块中cmo
的状态,所以我无法在[=15上执行上下文相关的命令=] 在 cd
调用之后。这令人沮丧...
首先,使用以下代码创建模块 wl.py:
# Caution: This file is part of the command scripting implementation.
# Do not edit or move this file because this may cause commands and scripts to fail.
# Do not try to reuse the logic in this file or keep copies of this file because this
# could cause your scripts to fail when you upgrade to a different version.
# Copyright (c) 2004,2014, Oracle and/or its affiliates. All rights reserved.
"""
This is WLST Module that a user can import into other Jython Modules
"""
from weblogic.management.scripting.utils import WLSTUtil
import sys
origPrompt = sys.ps1
theInterpreter = WLSTUtil.ensureInterpreter();
WLSTUtil.ensureWLCtx(theInterpreter)
execfile(WLSTUtil.getWLSTCoreScriptPath())
execfile(WLSTUtil.getWLSTNMScriptPath())
execfile(WLSTUtil.getWLSTScriptPath())
execfile(WLSTUtil.getOfflineWLSTScriptPath())
exec(WLSTUtil.getOfflineWLSTScriptForModule())
execfile(WLSTUtil.getWLSTCommonModulePath())
theInterpreter = None
sys.ps1 = origPrompt
modules = WLSTUtil.getWLSTModules()
for mods in modules:
execfile(mods.getAbsolutePath())
jmodules = WLSTUtil.getWLSTJarModules()
for jmods in jmodules:
fis = jmods.openStream()
execfile(fis, jmods.getFile())
fis.close()
wlstPrompt = "false"
接下来,将此模块导入您的 jms.py 模块并调用 wlst 命令,如下所示:wl.cd('...')
我正在创建一个脚本,以使用 wslt.sh
以声明方式自动创建 JMS 资源。这样我只需要 运行 wslt.sh create_resources.py planned_resources.properties
create_resources.py 导入了我的另一个模块 import include.jms as nmjms
。此 include/jms.py 调用 WSLT 的 cd
和 cmo
。
问题是,调用cd
不会改变jms.py模块中cmo
的状态,所以我无法在[=15上执行上下文相关的命令=] 在 cd
调用之后。这令人沮丧...
首先,使用以下代码创建模块 wl.py:
# Caution: This file is part of the command scripting implementation.
# Do not edit or move this file because this may cause commands and scripts to fail.
# Do not try to reuse the logic in this file or keep copies of this file because this
# could cause your scripts to fail when you upgrade to a different version.
# Copyright (c) 2004,2014, Oracle and/or its affiliates. All rights reserved.
"""
This is WLST Module that a user can import into other Jython Modules
"""
from weblogic.management.scripting.utils import WLSTUtil
import sys
origPrompt = sys.ps1
theInterpreter = WLSTUtil.ensureInterpreter();
WLSTUtil.ensureWLCtx(theInterpreter)
execfile(WLSTUtil.getWLSTCoreScriptPath())
execfile(WLSTUtil.getWLSTNMScriptPath())
execfile(WLSTUtil.getWLSTScriptPath())
execfile(WLSTUtil.getOfflineWLSTScriptPath())
exec(WLSTUtil.getOfflineWLSTScriptForModule())
execfile(WLSTUtil.getWLSTCommonModulePath())
theInterpreter = None
sys.ps1 = origPrompt
modules = WLSTUtil.getWLSTModules()
for mods in modules:
execfile(mods.getAbsolutePath())
jmodules = WLSTUtil.getWLSTJarModules()
for jmods in jmodules:
fis = jmods.openStream()
execfile(fis, jmods.getFile())
fis.close()
wlstPrompt = "false"
接下来,将此模块导入您的 jms.py 模块并调用 wlst 命令,如下所示:wl.cd('...')