Ignore:
Timestamp:
Oct 17, 2007 12:56:13 PM (13 years ago)
Author:
jpfasano
Message:

userConfig now has svn path for math01 machine
osCommand now has alternate implementation for older versions of python

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/testScripts/NBosCommand.py

    r629 r631  
    11#! /usr/bin/env python
    22
    3 import subprocess
     3from socket import gethostname
    44
    55#------------------------------------------------------------------------
     
    99#------------------------------------------------------------------------
    1010def run(cmd) :
    11   p=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    12   cmdStdout,cmdStderr=p.communicate()
    13   cmdRc=p.returncode
    14   retVal = { 'returnCode':cmdRc, 'stdout':cmdStdout, 'stderr':cmdStderr }
    15   return retVal
     11
     12  if gethostname()=='math01.watson.ibm.com' :
     13
     14    # this machine has a back level of python, so must use an older
     15    # techniques to implement this function.  This implementation
     16    # runs the command in the same process as the script.
     17    # This has the problem that if the command crashes, it will bring
     18    # down the script. Another problem is that stderr and stdout are
     19    # mingled together
     20
     21    import commands
     22    result = commands.getstatusoutput(cmd)
     23    retVal = { 'returnCode':result[0], 'stdout':result[1], 'stderr':'' }
     24    return retVal
     25
     26  else :
     27
     28    import subprocess
     29 
     30    p=subprocess.Popen(cmd,shell=True,\
     31                       stdout=subprocess.PIPE,\
     32                       stderr=subprocess.PIPE)
     33    cmdStdout,cmdStderr=p.communicate()
     34    cmdRc=p.returncode
     35    retVal = { 'returnCode':cmdRc, 'stdout':cmdStdout, 'stderr':cmdStderr }
     36    return retVal
    1637
    1738
Note: See TracChangeset for help on using the changeset viewer.