简体   繁体   中英

Assign output values to variables

My code is as follows:

import java.lang.System as sys
from time import strftime
cells = AdminConfig.list('Cell').split(lineSeparator)
for cell in cells:
    nodes = AdminConfig.list('Node', cell).split(lineSeparator)
    for node in nodes:
        cname = AdminConfig.showAttribute(cell, 'name')
        nname = AdminConfig.showAttribute(node, 'name')
        servs = AdminControl.queryNames('type=Server,cell=' + cname + ',node=' + nname + ',*').split(lineSeparator)
        if servs != ['']:
            for server in servs:
                sname = AdminControl.getAttribute(server, 'name')
                ptype = AdminControl.getAttribute(server, 'processType')
                pid   = AdminControl.getAttribute(server, 'pid')
                state = AdminControl.getAttribute(server, 'state')
                apps  = AdminControl.queryNames('type=Application,cell=' + cname + ',node=' + nname + ',process=' + sname + ',*').split(lineSeparator)
                if ( apps != [''] and sname != 'dmgr' ):
                    for app in apps:
                        aname = AdminControl.getAttribute(app, 'name')
                        print aname

My request is to list the application names as below.

wsadmin>execfile('C:/IBM/pyscripts/applist.py')
TradeWeb_war
ibmasyncrsp

So here I want to list the applications as 1, 2, 3 etc and redeploy the application on selection . Please help me to assign the output to a variable for selection.

Is this something you are looking for?

for app in apps:
        vars()[str(app)] = AdminControl.getAttribute(app, 'name')

Now if the name of app was TradeWeb_war :

Callling, TradeWeb_war will give you the value of:

AdminControl.getAttribute(TradeWeb_war, 'name')

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