模块化python脚本中的Weblogic WSLT

2024-09-30 01:30:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在创建一个脚本,使用wslt.sh以声明方式自动创建JMS资源。这样我只需要运行wslt.sh create_resources.py planned_resources.properties

创建_资源.py导入我的另一个模块import include.jms as nmjms。这包括/jms.py调用WSLT的cdcmo。在

问题是,调用cd并不会改变cmo的状态jms.py模块,这样我就不能在调用cd之后对cmo执行上下文相关的命令。这太令人沮丧了。。。在


Tags: 模块py脚本声明shcreate方式cd
1条回答
网友
1楼 · 发布于 2024-09-30 01:30:32

首先,创建一个模块工作日代码如下:

# 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公司(“…”)

相关问题 更多 >

    热门问题