title: [WebSphere]: Items are not properly appending to a list and regex is failing
body: <p>We are trying to stop a particular app without manual intervention through a combination of <code>AdminApp.list()</code> and <code>regex</code>.</p>
  
  <p><strong>The end target is</strong>: <strong><em>Ease of USE</em></strong>. A user must be able to stop an application without logging-in to a WAS console or modifying the target application name values in the script. They must login into Jenkins and execute this stopapp.py script. It must be that simple. </p>
  
  <p>According to this script, WAS returns a list of apps currently present in its DMGR. Then we append these items to an empty list, and then run a regex routine (re.match) to identify a particular app name. Then we substitute the extracted app name value in URI of the application which we are trying to stop. If successful, app will be stopped and status would be synced across nodes. </p>
  
  <p>Here is my <strong>code</strong>: </p>
  
  <pre><code>    import re
  
      moduleName = "meap"
      ctxRootOld = "/meap_old"
  
      appList = []
  
      appObj = AdminApp.list("WebSphere:cell=myCell,node=myNode,server=myServer")
      print("These are the list of apps running in WAS DMGR: ")
      print(appObj)
  
      for apps in appObj:
          appList.append(apps)
  
      print("Now appending the apps to an empty list...Here are the values")
      print(appList)
  
      for app in appList:
          appMatch = re.match("^ABC\w+$", app)
          print(appMatch)
          result = appMatch.group(0)
  
      appStopName = result
      print (appStopName)
  
      appStopURI = ""+appStopName+".war,WEB-INF/web.xml"
  
      appmanager = AdminControl.queryNames('cell=myCell,node=myNode,type=ApplicationManager,*')
  
      AdminControl.invoke(appmanager, 'stopApplication', appStopName)
  
      AdminApp.edit(appStopName, ['-CtxRootForWebMod', [[moduleName, appStopURI, ctxRootOld]]])
  
      AdminConfig.save()
  
      AdminNodeManagement.syncActiveNodes()
  </code></pre>
  
  <p>The <strong>output</strong> is as following:</p>
  
  <pre><code>WASX7209I: Connected to process "dmgr" on node CellManager03 using SOAP connector;  The type of process is: DeploymentManager
  
  These are the apps running in WAS DMGR:
  DefaultApp
  ABCPreProd
  
  Now appending the apps to an empty list...Here are the values
  ['D','e','f','a','u','l','t'.....'P','r','o','d']
  
  None
  
  WASX7017E: Exception received while running file "/app/was_scripts/stopapp.py"; exception information: com.ibm.bsf.BSFException: exception from Jython:
  Traceback (innermost last):
    File "&lt;string&gt;", line 11, in ?
  AttributeError: 'None' object has no attribute 'group'
  </code></pre>
  
  <p>Though it is printing a list (in a not-so proper format), but it is improperly appending to an empty list. It is taking each application name, then splitting them into individual letters, and then appending to an empty list. </p>
  
  <p>As a result, the regex pattern matching is returning <code>None</code> instead of app name.</p>
  
  <p>Please guide me so that I can rectify the error and automate this stuff. I feel a split method along with append will resolve the issue. But I don't know what kind of separator to put inside the split method. This is only my feeling, but everyone is free to send in their thoughts. </p>
  
  <p>Thanks and Regards- KrisT :) </p>