ajack       2004/07/14 13:47:03

  Modified:    python/gump/utils sync.py work.py tools.py
               python/gump/core gumprun.py config.py gumpenv.py options.py
               python/gump/model workspace.py state.py profile.py
               python/gump/update cvs.py svn.py artifact.py
               python/gump/test timing.py utils.py pyunit.py model.py
               python/gump/document/xdocs documenter.py
               python/gump/integration depot.py
               python/gump/build abstract.py
               python/gump/syndication atom.py
  Added:       python/gump/process __init__.py command.py .cvsignore
                        launcher.py
               python/gump/test launching.py
  Removed:     python/gump/utils launcher.py
  Log:
  1) Serious re-work on launching (in hope that is it multi-threaded)
  2) More cleanup of from X import *
  3) Publisher stuff (to Repo).
  
  Revision  Changes    Path
  1.20      +0 -1      gump/python/gump/utils/sync.py
  
  Index: sync.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/utils/sync.py,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- sync.py   8 Jul 2004 20:33:06 -0000       1.19
  +++ sync.py   14 Jul 2004 20:47:01 -0000      1.20
  @@ -27,7 +27,6 @@
   from gump import log
   from gump.utils.work import *
   from gump.utils.file import *
  -from gump.utils.launcher import *
   from gump.utils.note import *
   
   SYNC_ACTION=1
  
  
  
  1.17      +13 -3     gump/python/gump/utils/work.py
  
  Index: work.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/utils/work.py,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- work.py   8 Jul 2004 20:33:06 -0000       1.16
  +++ work.py   14 Jul 2004 20:47:01 -0000      1.17
  @@ -23,10 +23,11 @@
   
   from gump.model.state import *
   from gump.utils.owner import *
  -from gump.utils.launcher import *
   from gump.utils.timing import *
   from gump.utils import *
   
  +import gump.process.command
  +import gump.process.launcher
                  
   WORK_TYPE_CHECK=1
   WORK_TYPE_CONFIG=2
  @@ -120,11 +121,20 @@
                                   self.timerange.getStartTime(),
                                   self.timerange.getEndTime(),
                                   self.message)
  -        
  +       
  +       
  +CW_STATE_MAP = {   gump.process.command.CMD_STATE_NOT_YET_RUN : STATE_UNSET,
  +                   gump.process.command.CMD_STATE_SUCCESS : STATE_SUCCESS,
  +                   gump.process.command.CMD_STATE_FAILED : STATE_FAILED,
  +                   gump.process.command.CMD_STATE_TIMED_OUT : STATE_FAILED }
  +               
  +def commandStateToWorkState(state):
  +    return CW_STATE_MAP[state]
  +     
   class CommandWorkItem(TimedWorkItem):
       """ Unit of Work"""
       def __init__(self,type,command,result=None,message=''):
  -        if not result: result=CmdResult(command)
  +        if not result: result=gump.process.command.CmdResult(command)
           TimedWorkItem.__init__(self,command.name,type,\
                   commandStateToWorkState(result.state),       \
                   result.getStartSecs(),       \
  
  
  
  1.26      +4 -3      gump/python/gump/utils/tools.py
  
  Index: tools.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/utils/tools.py,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- tools.py  15 May 2004 18:02:31 -0000      1.25
  +++ tools.py  14 Jul 2004 20:47:01 -0000      1.26
  @@ -27,7 +27,8 @@
   from gump.utils.work import *
   from gump.utils.file import *
   from gump.utils.sync import *
  -from gump.utils.launcher import *
  +from gump.process.command import *
  +from gump.process.launcher import *
       
   def listDirectoryAsWork(workable,directory,name=None):
       ok=0
  @@ -35,7 +36,7 @@
       cmd=getCmdFromString("ls -l "+directory,name)
       try:
           result=execute(cmd)
  -        ok=result.state==CMD_STATE_SUCCESS 
  +        ok=result.state==gump.process.command.CMD_STATE_SUCCESS 
           if not ok:
               log.error('Failed to list [' + directory + ']')     
       except Exception, details:
  @@ -77,7 +78,7 @@
       cmd=getCmdFromString('cat '+str(file),'display_file_'+name)
       try:
           result=execute(cmd)
  -        ok=result.state==CMD_STATE_SUCCESS 
  +        ok=result.isOk() 
           if not ok:
               log.error('Failed to cat [' + str(file) + ']')     
       except Exception, details:
  
  
  
  1.14      +2 -2      gump/python/gump/core/gumprun.py
  
  Index: gumprun.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/core/gumprun.py,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- gumprun.py        14 Jul 2004 15:47:59 -0000      1.13
  +++ gumprun.py        14 Jul 2004 20:47:01 -0000      1.14
  @@ -233,7 +233,7 @@
           for actor in self.actors:
               log.debug('Dispatch Event : ' + `event` + ' to ' + `actor`)     
               actor._processEvent(event)
  -        inspectGarbageCollection(`event`)
  +        gump.utils.inspectGarbageCollection(`event`)
               
       def _dispatchRequest(self,request):
        """
  @@ -243,7 +243,7 @@
           for actor in self.actors:
               log.debug('Dispatch Request : ' + `request` + ' to ' + `actor`)       
               actor._processRequest(request)
  -        inspectGarbageCollection(`request`)
  +        gump.utils.inspectGarbageCollection(`request`)
               
       def generateEvent(self,entity):
           """
  
  
  
  1.9       +2 -1      gump/python/gump/core/config.py
  
  Index: config.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/core/config.py,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- config.py 13 Jul 2004 18:44:35 -0000      1.8
  +++ config.py 14 Jul 2004 20:47:01 -0000      1.9
  @@ -38,6 +38,8 @@
       cmdpath   = os.path.abspath(sys.argv[0])
       base      = os.path.abspath('%s/%s' % (os.path.dirname(cmdpath),'../..'))
       
  +    gump      = os.path.abspath(os.path.dirname(cmdpath))
  +    
       cache     = os.path.abspath('%s/%s' % (base,'cache'))
       work      = os.path.abspath('%s/%s' % (base,'work'))
       tmp       = os.path.abspath('%s/%s' % (base,'tmp'))
  @@ -101,7 +103,6 @@
       utctimeformat='%H:%M:%S (UTC)'
       
       timeout=60*60 # 60 minutes (in seconds)
  -    timeoutCommand=False
       
   class switch:
       """Configuration of switches """   
  
  
  
  1.9       +8 -13     gump/python/gump/core/gumpenv.py
  
  Index: gumpenv.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/core/gumpenv.py,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- gumpenv.py        13 Jul 2004 18:44:35 -0000      1.8
  +++ gumpenv.py        14 Jul 2004 20:47:01 -0000      1.9
  @@ -33,7 +33,10 @@
   
   from gump.utils.note import Annotatable
   from gump.utils.work import *
  -from gump.utils.launcher import *
  +
  +import gump.process.command
  +import gump.process.launcher
  +
   from gump.utils.tools import *
   
   from gump.model.state import *
  @@ -70,8 +73,7 @@
        
        self.noMaven=False       
        self.noDepot=False      
  -     self.noUpdate=False     
  -     self.noTimeout=False
  +     self.noUpdate=False    
        self.noSvn=False        
        self.noCvs=False        
           self.noJavaHome=False
  @@ -170,14 +172,7 @@
           if not self.noSvn and not self._checkExecutable('svn','--version',False):
               self.noSvn=True
               self.addWarning('"svn" command not found, no SVN repository updates')
  -        
  -        if not self.noTimeout:
  -            if       not self._checkExecutable('timeout','60 env',False): 
  -                self.noTimeout=True
  -                self.addWarning('"timeout" command not found, no in-line command 
time outs')
  -            else:
  -                setting.timeoutCommand=True
  -            
  +          
           if not self.noUpdate and \
               not 
self._checkExecutable(getDepotUpdateCmd(),'-version',False,False,'check_depot_update'):
 
               self.noUpdate=True
  @@ -244,9 +239,9 @@
           ok=False
           try:
               if not name: name='check_'+command
  -            cmd=getCmdFromString(command+" "+options,name)
  +            cmd=gump.process.command.getCmdFromString(command+" "+options,name)
               result=execute(cmd)
  -            ok=result.state==CMD_STATE_SUCCESS 
  +            ok=result.isOk()
               if not ok:
                   log.info('Failed to detect [' + command + ']')   
           except Exception, details:
  
  
  
  1.2       +6 -0      gump/python/gump/core/options.py
  
  Index: options.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/core/options.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- options.py        14 Jul 2004 15:47:59 -0000      1.1
  +++ options.py        14 Jul 2004 20:47:01 -0000      1.2
  @@ -200,6 +200,9 @@
           """
           self.objectives=objectives
           
  +    def getObjectives(self):
  +        return self.objectives
  +        
       def _testObjectiveIsSet(self,objective):
           """
           Helper to test a single objective
  @@ -213,6 +216,9 @@
           Set the features
           """
           self.features=features
  +        
  +    def getFeatures(self):
  +        return self.features
           
       def disableFeature(self,feature):        
           """
  
  
  
  1.1                  gump/python/gump/process/__init__.py
  
  Index: __init__.py
  ===================================================================
  #!/usr/bin/env python
  
  
  # Copyright 2003-2004 The Apache Software Foundation
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  # 
  #     http://www.apache.org/licenses/LICENSE-2.0
  # 
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  
  """
      Launch other commands:
      
      1) Can set $CWD
        2) Can set ENV
        
        Note: Implemented as a separate Python process since we can't
        (portably & thread-safe) do this in the same process.
        
  """
  
  
  # tell Python what modules make up the gump package
  __all__ = ["launcher","command"]
  
  
  1.1                  gump/python/gump/process/command.py
  
  Index: command.py
  ===================================================================
  #!/usr/bin/env python
  
  # Copyright 2003-2004 The Apache Software Foundation
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  # 
  #     http://www.apache.org/licenses/LICENSE-2.0
  # 
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  """
      Executing processes (CVS, ant, etc.) and capturing results
  """
  
  import os
  import sys
  import logging
  import signal
  
  from threading import Timer
      
  from string import split
  
  from gump import log
  from gump.core.config import *
  from gump.utils import *
  from gump.utils.timing import *
  
  CMD_STATE_NOT_YET_RUN=0
  CMD_STATE_SUCCESS=1
  CMD_STATE_FAILED=2
  CMD_STATE_TIMED_OUT=3
  
  states = { CMD_STATE_NOT_YET_RUN : "Not Run",
             CMD_STATE_SUCCESS : "Success",
             CMD_STATE_FAILED : "Failed",
             CMD_STATE_TIMED_OUT : "Timed Out" }
  
  class Parameter:
      """Name/Value"""
      def __init__(self,name,value=None,separator=' ',prefix=None):        
        #if not name:
        #    raise 'Unnamed Parameter'
        if not name: log.error('Unnamed Parameter')
        self.name=name
        self.value=value
        self.separator=separator
        self.prefix=prefix
      
          
      def isRequiresQuoting(self):
          if self.name:
              if ' ' in self.name: return 1
              if default.shellQuote in self.name: return 1
              if default.shellEscape in self.name: return 1
                          
          if self.value:
              if ' ' in self.value: return 1
              if default.shellQuote in self.value: return 1
              if default.shellEscape in self.value: return 1
              
          return 0
                  
      
  def getParameterFromString(strp):
      """Extract a Parameter Object from a String"""
      parts=split(strp,'=')
      partCount=len(parts)
      if partCount==1:
          pname=parts[0]
          pvalue=None
          psep=''
      elif partCount > 1:
          pname=parts[0]
          pvalue=parts[1]
          psep='='
      else:
          return None
          
      return Parameter(pname,pvalue,psep)
      
  class Parameters:
      """An ordered set of command line parameters w/ last overriding first"""
      def __init__(self):
        self.list=[]
        self.dict={}
        
      def addPrefixedParameter(self,prefix,name,value=None,separator=' '):
        self.addParameter(name,value,separator,prefix)
        
      def addPrefixedNamedParameter(self,prefix,name,value=None,separator=' '):
        self.addNamedParameter(name,value,separator,prefix)
        
      def addNamedParameter(self,name,value=None,separator=' ',prefix=None):
        if self.dict.has_key(name):
          self.removeParameter(name)
        self.addParameter(name,value,separator,prefix)
   
      def addNamedParameterObject(self,param):
        if self.dict.has_key(param.name):
          self.removeParameter(param.name)
        self.addParameterObject(param)
   
      def addParameter(self,name,value=None,separator=' ',prefix=None):
        param=Parameter(name,value,separator,prefix)
        self.addParameterObject(param)
        
      def addParameterObject(self,param):
        self.list.append(param)
        self.dict[param.name]=param
          
      def removeParameter(self,name):
        for param in self.list:
          if param.name==name: 
            self.list.remove(param)
            del self.dict[name]
      
      def formatCommandLine(self):
        line = ''
        for param in self.list:
          requiresQuoting=param.isRequiresQuoting()
          
          if requiresQuoting:
              line+=default.shellQuote
          
          if param.prefix: 
            line += param.prefix
            
          #
          # Deal w/ escaping quotes
          #
          line += self.getEscapedEntry(param.name)
          val = param.value
          if val:
              line += param.separator
              line += self.getEscapedEntry(val)        
              
          if requiresQuoting:
              line+=default.shellQuote            
          line += ' '
          
        return line
          
      def getEscapedEntry(self,entry):
          if not entry: return
          # Try without escape escape for now...
          
#escapedEntry=entry.replace(default.shellEscape,default.shellEscape+default.shellEscape)
        
          
escapedEntry=entry.replace(default.shellQuote,default.shellEscape+default.shellQuote)
          return escapedEntry
          
      def items(self):
        return self.list
        
      def dump(self,indent=''):
        for param in self.list:
          print indent+'  '+param.name+' '+str(param.value)+' ('+str(param.prefix)+')'
        
  class Cmd:
      """Command Line (executable plus parameters)"""
      def __init__(self,command,name=None,cwd=None,env=None,timeout=None):
          self.cmdpath=command
          self.name=name
          if not self.name:
              self.name=command
          self.params=Parameters()
          self.env=env
          if not env: self.env={}
          self.cwd=cwd
          self.timeout=timeout
  
      def addParameter(self,name,val=None,separator=' '):
          self.params.addParameter(name,val,separator)
          
      def addPrefixedParameter(self,prefix,name,val=None,separator=' '):
          self.params.addPrefixedParameter(prefix,name,val,separator)
          
      def addPrefixedParameters(self,prefix,params):
          for p in params.items():
            self.params.addPrefixedParameter(prefix,p.name,p.value,p.separator)
            
      def addPrefixedNamedParameters(self,prefix,params):
          for p in params.items():
            self.params.addPrefixedNamedParameter(prefix,p.name,p.value,p.separator)
  
      def addParameterObject(self,param):
          self.params.addParameterObject(param)
          
      def addParameters(self,params):
          for p in params.items():
            self.params.addParameter(p.name,p.value,p.separator,p.prefix)
          
      def addNamedParameters(self,params):
          for p in params.items():
            self.params.addNamedParameter(p.name,p.value,p.separator,p.prefix)
          
      def addEnvirionment(self,name,val=None):
          self.env[name]=val
          
      def formatCommandLine(self):
          line = str(self.cmdpath)
          line += " "
          line += self.params.formatCommandLine()
          return line
              
      def overview(self,indent=''):
          overview=indent+'Command Line: ' + self.formatCommandLine()+'\n'
          if self.cwd:
              overview += indent+'[Working Directory: ' + self.cwd + ']\n'
          if self.env:
              for envKey in self.env.keys():
                  overview += indent+envKey+' : '+self.env[envKey]
          return overview
          
      def dump(self,indent=''):
          print self.overview(indent)
          
  def getCmdFromString(strcmd,name=None):
      """Extract a Cmd Object from a String"""
      parts=split(strcmd,' ')
      cmdcmd=parts[0]
      if not name: name=cmdcmd
      cmd=Cmd(cmdcmd,name)
      for i in range(1,len(parts)):
          if parts[i]:
              cmd.addParameterObject(getParameterFromString(parts[i]))
      return cmd
                  
  class CmdResult:
      """Result of execution -- state/outputs"""
      def __init__(self,cmd):
          self.cmd=cmd
          self.state=CMD_STATE_NOT_YET_RUN
          self.output=None
          self.signal=0
          self.exit_code=-1
          
          # To calculate elapsed
          self.start_time=None
          self.end_time=None
          
      def overview(self,indent):
          overview = indent+"State: " + states[self.state]
          overview += self.cmd.overview(indent)
          if self.output:
            overview += indent+"Output: " + self.output
          if self.hasTimes():
            overview += indent+"Elapsed: " + 
secsToElapsedTimeString(self.getElapsedSecs())
          if self.signal:
            overview += indent+"Termination Signal: " + str(self.signal)
          if self.exit_code:
            overview += indent+"ExitCode: " + str(self.exit_code)
          
          return overview
          
      def tail(self,lines,wrapLen=0,eol=None,marker=None):                
          if self.output:
              from gump.utils.tools import tailFileToString            
              tail = tailFileToString(self.output,lines,wrapLen,eol,marker)
          else:
              tail = "No output\n"
              
          return tail
          
      def isOk(self):
          return (self.state==CMD_STATE_SUCCESS)
      
      def hasOutput(self):
          if self.output: return 1
          return 0
          
      def getOutput(self):
          return self.output
          
      def hasTimes(self):
          if self.start_time and self.end_time: return 1
          return 0
          
      def getStartSecs(self):
          return self.start_time
          
      def getEndSecs(self):
          return self.end_time
          
      def getElapsedSecs(self):
          return int(round(self.end_time-self.start_time,0))        
          
      def dump(self,indent):
          print self.overview(indent)
  
    
  
  
  
  1.1                  gump/python/gump/process/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  *.pyc
  
  
  
  1.1                  gump/python/gump/process/launcher.py
  
  Index: launcher.py
  ===================================================================
  #!/usr/bin/env python
  
  # Copyright 2003-2004 The Apache Software Foundation
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  # 
  #     http://www.apache.org/licenses/LICENSE-2.0
  # 
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  """
      Executing processes (CVS, ant, etc.) and capturing results
  """
  
  import os
  import sys
  import logging
  import signal
  
  from string import split
  
  from gump import log
  from gump.core.config import dir
  from gump.utils import *
  from gump.utils.timing import *
  
  import gump.process.command
  
  LAUNCHER=os.path.join(os.path.join('gump','process'),'launcher.py')
  
  def execute(cmd,tmp=dir.tmp):
      res=gump.process.command.CmdResult(cmd)
      return executeIntoResult(cmd,res,tmp)
        
  def executeIntoResult(cmd,result,tmp=dir.tmp):
      """
      
        Execute a command and capture the result
     
        """     
      
      outputFile=None
      start_time=time.time()
      try:
        try:          
   
          # The command line
          execString=cmd.formatCommandLine()        
          
          # Exec File
          execFile=os.path.abspath(os.path.join(tmp,gumpSafeName(cmd.name)+'.exec'))
          if os.path.exists(execFile): os.remove(execFile)
          
          # Output
          outputFile=os.path.abspath(os.path.join(tmp,gumpSafeName(cmd.name)+'.txt'))
          if os.path.exists(outputFile): os.remove(outputFile)
      
          try:            
              f=open(execFile, 'w')
              
              # The CMD
              f.write( 'CMD: %s\n' % (execString))
                  
              # Dump the TMP
              if tmp:
                  f.write( 'TMP: %s\n' % (tmp))
                  
              # Dump the cwd (if specified)
              if cmd.cwd:
                  f.write( 'CWD: %s\n' % (cmd.cwd))
                       
              # Write ENV over-writes...
              for envKey in cmd.env.iterkeys():
                  f.write('%s: %s\n' % (envKey, cmd.env[envKey]))    
   
          finally:
              # Since we may exit via an exception, close explicitly.
              if f: f.close()    
              
          #############################################################          
             
          fullExec = sys.executable + ' ' + LAUNCHER + ' ' + execFile + \
                                      ' >>' + str(outputFile) + ' 2>&1'
                                      
          log.debug('Executing: ' + execString)
          log.debug('     Exec: ' + str(execFile))
          log.debug('   Output: ' + str(outputFile))
          log.debug('Full Exec: ' + fullExec)
          
          # Execute Command & Wait
          systemReturn=os.system(fullExec)
          
          if not os.name == 'dos' and not os.name == 'nt':
              waitcode=systemReturn
          
              #
              # The return code (from system = from wait) is (on Unix):
              #
              # a 16 bit number
              # top byte        =       exit status
              # low byte        =       signal that killed it
              #
              result.signal=(waitcode & 0xFF)
              result.exit_code=(((waitcode & 0xFF00) >> 8) & 0xFF)
          
          else:
              
              result.signal=0
              result.exit_code=systemReturn
              
          log.debug('Command returned [' + str(systemReturn)+ '] [Sig:' + 
str(result.signal) + ' / Exit:' + str(result.exit_code) + '].')
          
          #
          # Assume timed out if signal terminated
          #
          if result.signal > 0:
              result.state=gump.process.command.CMD_STATE_TIMED_OUT
              log.warn('Command timed out. [' + execString + '] [' + str(timeout) + '] 
seconds.')
          # Process Outputs (exit_code and stderr/stdout)
          elif result.exit_code > 0:    
              result.state=gump.process.command.CMD_STATE_FAILED
              log.warn('Command failed. [' + execString + ']. ExitCode: ' + 
str(result.exit_code))
          else:
              result.state=gump.process.command.CMD_STATE_SUCCESS                
       
        except Exception, details :
          log.error('Failed to launch command. Details: ' + str(details))
          
          result.exit_code=-1
          result.state=gump.process.command.CMD_STATE_FAILED
          
      finally:
        # Clean Up Empty Output Files
        if outputFile and os.path.exists(outputFile):
            if os.path.getsize(outputFile) > 0:
                result.output=outputFile
            else:
                os.remove(outputFile)
          
        # Keep time information
        end_time=time.time()
        result.start_time=start_time
        result.end_time=end_time 
          
      return result
          
      
  if __name__=='__main__':
      import re
      
      exit_code=0
      execFilename=sys.argv[1]
      execFile=None
      try:
          execFile=file(execFilename,'r')
      
          # Split into a dict of NAME: VALUE (from file)
          execInfo=dict(re.findall('(.*?): (.*)', execFile.read()))
          
          #print execInfo
          #for key in execInfo.iterkeys():
          #    print 'KEY : ' + key  + ' -> ' + execInfo[key]
          
          cmd=execInfo['CMD']
          cwd=None
          if execInfo.has_key('CWD'):cwd=execInfo['CWD']
          tmp=execInfo['TMP']
         
          # Make the TMP if needed
          if not os.path.exists(tmp): os.makedirs(tmp)
         
          # Make the CWD if needed
          if cwd: 
            cwdpath=os.path.abspath(cwd)
            if not os.path.exists(cwdpath): os.makedirs(cwdpath)
            os.chdir(cwdpath)
         
          systemReturn=os.system(cmd)
          
          if not os.name == 'dos' and not os.name == 'nt':
              waitcode=systemReturn
          
              #
              # The return code (from system = from wait) is (on Unix):
              #
              #    a 16 bit number
              #    top byte    =    exit status
              #    low byte    =    signal that killed it
              #
              signal=(waitcode & 0xFF)
              exit_code=(((waitcode & 0xFF00) >> 8) & 0xFF)
          
          else:
              signal=0
              exit_code=systemReturn
              
      finally:
          if execFile: execFile.close()
          
      # print 'Exit: ' + `exit_code`
      sys.exit(exit_code)
          
    
    
  
  
  
  1.54      +0 -1      gump/python/gump/model/workspace.py
  
  Index: workspace.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/workspace.py,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- workspace.py      13 Jul 2004 18:44:36 -0000      1.53
  +++ workspace.py      14 Jul 2004 20:47:01 -0000      1.54
  @@ -21,7 +21,6 @@
   from string import lower, capitalize
   
   from gump.utils.work import *
  -from gump.utils.launcher import *
   from gump.utils.tools import *
   
   from gump.model.state import *
  
  
  
  1.16      +8 -14     gump/python/gump/model/state.py
  
  Index: state.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/state.py,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- state.py  8 Jul 2004 20:33:07 -0000       1.15
  +++ state.py  14 Jul 2004 20:47:01 -0000      1.16
  @@ -15,12 +15,10 @@
   # limitations under the License.
   
   """
  -    This module contains information on
  -"""
   
  -from time import localtime, strftime, tzname
  +     State information    
   
  -from gump.utils.launcher import *
  +"""
   
   STATE_UNSET=0
   STATE_NONE=1
  @@ -73,16 +71,7 @@
       
   def stateForDescription(name):
       return describedState.get(name,STATE_UNSET)
  -
  -stateMap = {   CMD_STATE_NOT_YET_RUN : STATE_UNSET,
  -               CMD_STATE_SUCCESS : STATE_SUCCESS,
  -               CMD_STATE_FAILED : STATE_FAILED,
  -               CMD_STATE_TIMED_OUT : STATE_FAILED }
  -               
  -def commandStateToWorkState(state):
  -    return stateMap[state]
              
  -
   REASON_UNSET=0
   REASON_PACKAGE=1
   REASON_PACKAGE_BAD=2
  @@ -228,7 +217,12 @@
           return self.isFailed() or self.isPrereqFailed()
                  
   class Stateful:
  -    def __init__(self):        
  +    def __init__(self):  
  +        """
  +             
  +             An entity that holds state
  +                   
  +        """
           self.statePair=StatePair()
           
       def setStatePair(self,statePair):  
  
  
  
  1.7       +0 -1      gump/python/gump/model/profile.py
  
  Index: profile.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/profile.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- profile.py        8 Jul 2004 20:33:07 -0000       1.6
  +++ profile.py        14 Jul 2004 20:47:01 -0000      1.7
  @@ -22,7 +22,6 @@
   from string import lower, capitalize
   
   from gump.utils.work import *
  -from gump.utils.launcher import *
   from gump.utils.tools import *
   
   from gump.model.state import *
  
  
  
  1.7       +3 -5      gump/python/gump/update/cvs.py
  
  Index: cvs.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/update/cvs.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- cvs.py    8 Jul 2004 20:33:09 -0000       1.6
  +++ cvs.py    14 Jul 2004 20:47:02 -0000      1.7
  @@ -95,11 +95,9 @@
           work=CommandWorkItem(WORK_TYPE_UPDATE,cmd,cmdResult)
           module.performedWork(work)  
        
  -        if not cmdResult.state==CMD_STATE_SUCCESS:              
  +        if not cmdResult.isOk():              
               log.error('Failed to checkout/update module: ' + module.name)   
  -                                                            
  -     
  -        
  +                                  
       def performUpdate(self,module,exists):
           """
               Update this module (checking out if needed)
  @@ -126,7 +124,7 @@
           repository.performedWork(work.clone())
         
           # Update Context w/ Results  
  -        if not cmdResult.state==CMD_STATE_SUCCESS:              
  +        if not cmdResult.isOk():              
               log.error('Failed to checkout/update module: ' + module.name)   
               if not exists:     
                   module.changeState(STATE_FAILED,REASON_UPDATE_FAILED)
  
  
  
  1.6       +2 -2      gump/python/gump/update/svn.py
  
  Index: svn.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/update/svn.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- svn.py    8 Jul 2004 20:33:08 -0000       1.5
  +++ svn.py    14 Jul 2004 20:47:02 -0000      1.6
  @@ -88,7 +88,7 @@
           module.performedWork(work)  
         
           # Update Context w/ Results  
  -        if not cmdResult.state==CMD_STATE_SUCCESS:              
  +        if not cmdResult.isOk():              
               message='Failed to \'status --show-updates\' module: ' + 
module.getName()
               module.addWarning(message)
               log.error(message)               
  @@ -163,7 +163,7 @@
           repository.performedWork(work.clone())
         
           # Update Context w/ Results  
  -        if not cmdResult.state==CMD_STATE_SUCCESS:              
  +        if not cmdResult.isOk():              
               log.error('Failed to checkout/update module: ' + module.name)   
               if not exists:     
                   module.changeState(STATE_FAILED,REASON_UPDATE_FAILED)
  
  
  
  1.3       +1 -1      gump/python/gump/update/artifact.py
  
  Index: artifact.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/update/artifact.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- artifact.py       8 Jul 2004 20:33:09 -0000       1.2
  +++ artifact.py       14 Jul 2004 20:47:02 -0000      1.3
  @@ -78,7 +78,7 @@
           module.getRepository().performedWork(work.clone())
         
           # Update Context w/ Results  
  -        if not cmdResult.state==CMD_STATE_SUCCESS:              
  +        if not cmdResult.isOk():              
               log.error('Failed to checkout/update module: ' + module.name)   
               if not exists:     
                   module.changeState(STATE_FAILED,REASON_UPDATE_FAILED)
  
  
  
  1.3       +0 -1      gump/python/gump/test/timing.py
  
  Index: timing.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/test/timing.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- timing.py 8 Jul 2004 20:33:08 -0000       1.2
  +++ timing.py 14 Jul 2004 20:47:02 -0000      1.3
  @@ -18,7 +18,6 @@
   """
   
   from gump.utils import *
  -from gump.utils.launcher import *
   from gump.test.pyunit import UnitTestSuite
   
   class TimingTestSuite(UnitTestSuite):
  
  
  
  1.15      +1 -25     gump/python/gump/test/utils.py
  
  Index: utils.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/test/utils.py,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- utils.py  8 Jul 2004 20:33:08 -0000       1.14
  +++ utils.py  14 Jul 2004 20:47:02 -0000      1.15
  @@ -18,7 +18,6 @@
   """
   
   from gump.utils import *
  -from gump.utils.launcher import *
   from gump.test.pyunit import UnitTestSuite
   
   class TestBean:
  @@ -107,27 +106,4 @@
                   
       def testRefCounts(self):
           getRefCounts()     
  -        printTopRefs(100)       
  -        
  -    def testGoodLaunch(self):
  -        env=Cmd('env')
  -        result=execute(env)
  -        self.assertEqual('Ought succeed', result.state,CMD_STATE_SUCCESS)
  -
  -    def testBadLaunch(self):
  -        env=Cmd('eXnXv')
  -        result=execute(env)
  -        self.assertEqual('Ought failed', result.state, CMD_STATE_FAILED)
  -  
  -    def testFailedLaunch(self):      
  -        env=Cmd('exit 2')
  -        result=execute(env)
  -        self.assertEqual('Ought failed', result.state, CMD_STATE_FAILED)
  -        self.assertEqual('Ought failed', result.exit_code, 2)
  -        
  -    def testFailedLaunch2(self):      
  -        env=Cmd('exit 70')
  -        result=execute(env)
  -        self.assertEqual('Ought failed', result.state, CMD_STATE_FAILED)
  -        self.assertEqual('Ought failed', result.exit_code, 70)
  -  
  +        printTopRefs(100)       
  \ No newline at end of file
  
  
  
  1.35      +3 -0      gump/python/gump/test/pyunit.py
  
  Index: pyunit.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/test/pyunit.py,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- pyunit.py 14 Jul 2004 15:47:59 -0000      1.34
  +++ pyunit.py 14 Jul 2004 20:47:02 -0000      1.35
  @@ -371,6 +371,9 @@
       from gump.test.artifacts import ArtifactsTestSuite  
       runner.addSuite(ArtifactsTestSuite())
       
  +    from gump.test.launching import LaunchingTestSuite  
  +    runner.addSuite(LaunchingTestSuite())
  +    
       # Any args are pattern matches
       patterns=list(sys.argv)
       del patterns[0:1]
  
  
  
  1.23      +3 -4      gump/python/gump/test/model.py
  
  Index: model.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/test/model.py,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- model.py  8 Jul 2004 20:33:08 -0000       1.22
  +++ model.py  14 Jul 2004 20:47:02 -0000      1.23
  @@ -79,8 +79,6 @@
           self.assertTrue('Has Jars', self.package1.hasJars())
           self.assertTrue('Is a package', self.packagedModule1.isPackaged())
           
  -        
  -        
       def testRepository(self):
           repo1 = self.repo1
           
  @@ -89,6 +87,7 @@
           #self.assertNonZeroString('Repository WEB str 
attr',str(getattr(repo1.xml,'cvsweb')))
           
           self.assertTrue('Repository has WEB',repo1.hasWeb())
  +        self.assertTrue('Repository is redistributable',repo1.isRedistributable())
           
           self.assertNonZero('Repository WEB',repo1.getWeb())
           self.assertNonZeroString('Repository WEB',repo1.getWeb())        
  
  
  
  1.1                  gump/python/gump/test/launching.py
  
  Index: launching.py
  ===================================================================
  #!/usr/bin/env python
  # Copyright 2003-2004 The Apache Software Foundation
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  # 
  #     http://www.apache.org/licenses/LICENSE-2.0
  # 
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  """
      Utility Testing
  """
  
  from gump.utils import *
  import gump.process.command
  import gump.process.launcher
  from gump.test.pyunit import UnitTestSuite
  
  class LaunchingTestSuite(UnitTestSuite):
      def __init__(self):
          UnitTestSuite.__init__(self)
          
      def testGoodLaunch(self):
          env=gump.process.command.Cmd('env')
          result=gump.process.launcher.execute(env)
          self.assertEqual('Ought succeed', result.state, 
gump.process.command.CMD_STATE_SUCCESS)
          self.assertTrue('Ought succeed', result.isOk())
  
      def testBadLaunch(self):
          env=gump.process.command.Cmd('eXnXv')
          result=gump.process.launcher.execute(env)
          self.assertEqual('Ought failed', result.state, 
gump.process.command.CMD_STATE_FAILED)
    
      def testFailedLaunch(self):      
          env=gump.process.command.Cmd('exit 2')
          result=gump.process.launcher.execute(env)
          self.assertEqual('Ought failed', result.state, 
gump.process.command.CMD_STATE_FAILED)
          self.assertEqual('Ought failed', result.exit_code, 2)
          
      def testFailedLaunch2(self):      
          env=gump.process.command.Cmd('exit 70')
          result=gump.process.launcher.execute(env)
          self.assertEqual('Ought failed', result.state, 
gump.process.command.CMD_STATE_FAILED)
          self.assertEqual('Ought failed', result.exit_code, 70)
    
  
  
  
  1.19      +1 -1      gump/python/gump/document/xdocs/documenter.py
  
  Index: documenter.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/document/xdocs/documenter.py,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- documenter.py     14 Jul 2004 19:26:46 -0000      1.18
  +++ documenter.py     14 Jul 2004 20:47:02 -0000      1.19
  @@ -1623,7 +1623,7 @@
                   repoList.createEntry( "SVN URL: ", module.svn.getRootUrl())         
        
   
               if module.hasArtifacts():
  -                if module.jars.hasUrl():
  +                if module.artifacts.hasUrl():
                       repoList.createEntry( "Jars URL: ", module.jars.getUrl())   
   
               repoList.createEntry('Redistributable: ', `module.isRedistributable()`) 
             
  
  
  
  1.3       +1 -2      gump/python/gump/integration/depot.py
  
  Index: depot.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/integration/depot.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- depot.py  8 Jul 2004 20:33:08 -0000       1.2
  +++ depot.py  14 Jul 2004 20:47:02 -0000      1.3
  @@ -36,9 +36,8 @@
               os.path.join(getDepotHome(),'bin'),
               'update.py')
       
  -    
   def getDepotUpdateCmd():
  -    return sys.executable+getDepotUpdatePath()
  +    return sys.executable+' '+getDepotUpdatePath()
       
       
   
  
  
  
  1.6       +2 -2      gump/python/gump/build/abstract.py
  
  Index: abstract.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/build/abstract.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- abstract.py       13 Jul 2004 22:53:37 -0000      1.5
  +++ abstract.py       14 Jul 2004 20:47:02 -0000      1.6
  @@ -23,7 +23,7 @@
   
   from gump import log
   import gump.core.gumprun
  -import gump.utils.launcher
  +import gump.process.command
   
   ###############################################################################
   # Classes
  @@ -36,7 +36,7 @@
   
       def getJVMArgs(self,project):
           """ Get JVM arguments for a project """
  -        args=gump.utils.launcher.Parameters()
  +        args=gump.process.command.Parameters()
           
           for jvmarg in project.getDomChildIterator('jvmarg'):
               if hasDomAttribute(jvmarg,'value'):                
  
  
  
  1.19      +1 -1      gump/python/gump/syndication/atom.py
  
  Index: atom.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/syndication/atom.py,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- atom.py   8 Jul 2004 20:33:08 -0000       1.18
  +++ atom.py   14 Jul 2004 20:47:02 -0000      1.19
  @@ -20,7 +20,7 @@
   """
   
   import os
  -from time import strftime, gmtime
  +import time
   
   from xml.sax.saxutils import escape
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to