gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject cvs commit: jakarta-gump/python/gump tools.py update.py model.py launcher.py context.py build.py logic.py check.py utils.py document.py conf.py
Date Tue, 23 Sep 2003 23:16:20 GMT
ajack       2003/09/23 16:16:20

  Modified:    python/gump update.py model.py launcher.py context.py
                        build.py logic.py check.py utils.py document.py
                        conf.py
  Added:       python/gump tools.py
  Log:
  1) Add tools (contained, for now, list a directory and call it work..)
  2) List project home directories when fail to find outputs (or packaged files)
  3) A lot of normpath to abspath (just 'cos it seems cleaner).
  4) Made some lists tables, and added extra columns
  5) Made "packaged projects" link to their pages.
  6) Made "packaged projects" be document as such (on their page).
  7) Project page references module page
  8) Removed *_env.txt in favour of writting into *.txt [switchable]
  9) Added switches.debugging for 8 and others.
  
  Revision  Changes    Path
  1.10      +7 -9      jakarta-gump/python/gump/update.py
  
  Index: update.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/update.py,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- update.py	23 Sep 2003 15:13:08 -0000	1.9
  +++ update.py	23 Sep 2003 23:16:20 -0000	1.10
  @@ -119,19 +119,18 @@
     log.debug("Workspace CVS Directory: " + workspace.cvsdir)
   
     log.info('Modules to update:') 
  -  for module in modules:            
  -    if not module.cvs: continue
  -    log.info('  - ' + module.name)
       
     # Update all the modules that have CVS repositories
  -  for module in modules:            
  +  for module in modules:          
       if not module.cvs: continue
  +    log.info('  - ' + module.name)
       
       name=module.name
   
       mctxt = context.getModuleContextForModule(module)
       
  -    if mctxt.okToPerformWork():
  +    if mctxt.okToPerformWork() \
  +        and not switches.failtesting:
           try:
             log.info("CVS Update Module " + name + ", Repository Name: " + str(module.cvs.repository))
   
  @@ -178,7 +177,6 @@
             
             # Testing...
             cmdResult=execute(cmd,workspace.tmpdir)
  -          #cmdResult=dummyExecute(cmd)
         
             work=CommandWorkItem(WORK_TYPE_UPDATE,cmd,cmdResult)
       
  
  
  
  1.17      +9 -9      jakarta-gump/python/gump/model.py
  
  Index: model.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model.py,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- model.py	11 Sep 2003 21:11:42 -0000	1.16
  +++ model.py	23 Sep 2003 23:16:20 -0000	1.17
  @@ -243,22 +243,22 @@
       if self.home and isinstance(self.home,Single):
         if self.home.nested:
           srcdir=Module.list[self.module].srcdir
  -        self.home=os.path.normpath(os.path.join(srcdir,self.home.nested))
  +        self.home=os.path.abspath(os.path.join(srcdir,self.home.nested))
         elif self.home.parent:
  -        self.home=os.path.normpath(os.path.join(workspace.basedir,self.home.parent))
  +        self.home=os.path.abspath(os.path.join(workspace.basedir,self.home.parent))
       elif not self.home:
         from gump.logic import isPackaged    
         if isPackaged(self):
  -        self.home=os.path.join(workspace.pkgdir,self.package)
  +        self.home=os.path.abspath(os.path.join(workspace.pkgdir,self.package))
         elif self.module:
  -        self.home=Module.list[self.module].srcdir
  +        self.home=os.path.abspath(Module.list[self.module].srcdir)
         else:
  -        self.home=os.path.join(workspace.basedir,self.name)
  +        self.home=os.path.abspath(os.path.join(workspace.basedir,self.name))
   
       # resolve jars
       for jar in self.jar:
         if self.home and jar.name:
  -        jar.path=os.path.normpath(os.path.join(self.home,jar.name))
  +        jar.path=os.path.abspath(os.path.join(self.home,jar.name))
   
       # expand properties
       if self.ant: self.ant.expand(self)
  
  
  
  1.3       +35 -22    jakarta-gump/python/gump/launcher.py
  
  Index: launcher.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/launcher.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- launcher.py	10 Sep 2003 14:25:07 -0000	1.2
  +++ launcher.py	23 Sep 2003 23:16:20 -0000	1.3
  @@ -276,37 +276,50 @@
       
       start_time=time.time()
       try:
  -      try:
  -        # Output
  -        outputFile=os.path.abspath(os.path.join(tmp,gumpSafeName(cmd.name)+'.txt'))
  -        if os.path.exists(outputFile): os.remove(outputFile)
  -    
  -        #############################################################
  -        # Possibly temporary, pos perm, for testing...
  -        # Environment
  -        envFile=os.path.abspath(os.path.join(tmp,gumpSafeName(cmd.name)+'.env.txt'))
  -        if os.path.exists(envFile): os.remove(envFile)
  -    
  -        try:            
  -            f=open( envFile, 'w')
  -            for envKey in os.environ.iterkeys():
  -                f.write('%s = %s\n' % (envKey, os.environ[envKey]))
  -        finally:
  -            # Since we may exit via an exception, close fp explicitly.
  -            if f: f.close()    
  -        #############################################################3
  -        
  +      try:          
  +        # Make the CWED if needed
           if cmd.cwd: 
             cwdpath=os.path.abspath(cmd.cwd)
             if not os.path.exists(cwdpath): os.mkdir(cwdpath)
             os.chdir(cwdpath)
           
  -        execString=cmd.formatCommandLine()
  +        # The command line
  +        execString=cmd.formatCommandLine()        
           
  +        # Output
  +        outputFile=os.path.abspath(os.path.join(tmp,gumpSafeName(cmd.name)+'.txt'))
  +        if os.path.exists(outputFile): os.remove(outputFile)
  +    
  +        if switches.debugging:
  +            #############################################################
  +            # This debug might become permenant ...
  +            #############################################################
  +            try:            
  +                f=open(outputFile, 'w')
  +                # Dump the command line
  +                printSeparatorToFile(f)    
  +                f.write( 'Command Line: %s\n' % (execString))
  +                # Dump the cwd (if specified)
  +                if cmd.cwd:
  +                    printSeparatorToFile(f)            
  +                    f.write( 'Working Directory: %s\n' % (cmd.cwd))
  +                # Dump the environment
  +                printSeparatorToFile(f)
  +                f.write( 'Environment:\n')
  +                for envKey in os.environ.iterkeys():
  +                    f.write('%s = %s\n' % (envKey, os.environ[envKey]))
  +                # Gap before the real stuff...
  +                printSeparatorToFile(f)
  +                f.write('\n\n')
  +            finally:
  +                # Since we may exit via an exception, close explicitly.
  +                if f: f.close()    
  +            
  +        #############################################################                
           log.info('Executing: ' + execString + ' (Output to ' + str(outputFile) + ')')
       
           # Execute Command & Wait
  -        result.exit_code=os.system(execString + ' >' + str(outputFile) + ' 2>&1')
  +        result.exit_code=os.system(execString + ' >>' + str(outputFile) + ' 2>&1')
       
           # Process Outputs (exit_code and stderr/stdout)
           if result.exit_code < 0:
  
  
  
  1.7       +3 -2      jakarta-gump/python/gump/context.py
  
  Index: context.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/context.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- context.py	23 Sep 2003 15:13:08 -0000	1.6
  +++ context.py	23 Sep 2003 23:16:20 -0000	1.7
  @@ -512,8 +512,9 @@
               #
               #
               #
  -            message = "failed with: " + lower(stateName(state)) \
  -                + " with reason: " + lower(reasonString(reason))            
  +            message = lower(stateName(state))
  +            if not REASON_UNSET == reason:
  +                message += " with reason " + lower(reasonString(reason))            
               self.addError(capitalize(message))
               
               #
  
  
  
  1.12      +12 -5     jakarta-gump/python/gump/build.py
  
  Index: build.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/build.py,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- build.py	23 Sep 2003 15:13:08 -0000	1.11
  +++ build.py	23 Sep 2003 23:16:20 -0000	1.12
  @@ -78,6 +78,7 @@
   from gump.model import Workspace, Module, Project
   from gump.launcher import Cmd, CmdResult, execute
   from gump.utils import dump
  +from gump.tools import listDirectoryAsWork
   
   ###############################################################################
   # Initialize
  @@ -145,7 +146,10 @@
         
       (mctxt) = context.getModuleContextForModule(module)
         
  -    if mctxt.okToPerformWork() and Module.list.has_key(module.name):
  +    if mctxt.okToPerformWork() \
  +        and Module.list.has_key(module.name) \
  +        and not switches.failtesting:
  +            
           module=Module.list[module.name];
           sourcedir = os.path.abspath(os.path.join(workspace.cvsdir,module.name)) # todo
allow override
           destdir = os.path.abspath(workspace.basedir)
  @@ -228,7 +232,10 @@
                               outputsOk=0
                               pctxt.addError("Missing Output: " + str(jar))
   
  -                if outputsOk: pctxt.status=STATUS_SUCCESS  
  +                if outputsOk: 
  +                    pctxt.status=STATUS_SUCCESS  
  +                elif project.home:
  +                    listDirectoryAsWork(pctxt,project.home,'list_'+project.name)      
       else:
           # :TODO: Redundant? 
           #
  
  
  
  1.3       +13 -1     jakarta-gump/python/gump/logic.py
  
  Index: logic.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/logic.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- logic.py	23 Sep 2003 15:13:08 -0000	1.2
  +++ logic.py	23 Sep 2003 23:16:20 -0000	1.3
  @@ -76,6 +76,7 @@
   from gump.conf import dir, default, handleArgv
   from gump.model import Workspace, Module, Project
   from gump.context import *
  +from gump.tools import listDirectoryAsWork
   
   ###############################################################################
   # Initialize
  @@ -339,6 +340,8 @@
           # If so far so good, check packages
           if isPackaged(project):
               
  +            pctxt.addInfo("This is a packaged project, location: " + str(project.home))
  +                        
               #
               # Check the package was installed correctly...
               #
  @@ -356,6 +359,11 @@
               if outputsOk:
                   pctxt.state=STATUS_COMPLETE
                   pctxt.reason=REASON_PACKAGE
  +                
  +            #
  +            # List them, why not...
  +            #
  +            listDirectoryAsWork(pctxt,project.home,'list_package_'+project.name)      
         
           else:         
               # Check Dependencies Exists:
               for depend in project.depend:
  @@ -382,11 +390,15 @@
           # well be considered complete, no need to update from CVS
           # since we won't be building.
           # :TODO: Ought we hack this as *any* not all???
  +        packageCount=0
           allPackaged=1
           for project in module.project:
               if not isPackaged(project):
                   allPackaged=0  
  -                mctxt.addWarning("Incomplete \'Packaged\' Module. Project: " + project.name
+ " is not packaged")                  
  +                if packageCount:
  +                    mctxt.addWarning("Incomplete \'Packaged\' Module. Project: " + project.name
+ " is not packaged")                  
  +            else:
  +                packageCount+=1
                   
           if allPackaged:
               mctxt.state=STATUS_COMPLETE
  
  
  
  1.19      +4 -4      jakarta-gump/python/gump/check.py
  
  Index: check.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/check.py,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- check.py	23 Sep 2003 15:13:08 -0000	1.18
  +++ check.py	23 Sep 2003 23:16:20 -0000	1.19
  @@ -142,7 +142,7 @@
           
       if not checkExecutable(workspace, context, 'rsync','-help',0): 
           context.noRSync=1
  -        context.addWarning('"rsync" command not found, no using recursive copy')
  +        context.addWarning('"rsync" command not found, so attempting recursive copy "cp
-R"')
           
       
       # :TODO:
  
  
  
  1.2       +5 -2      jakarta-gump/python/gump/utils.py
  
  Index: utils.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- utils.py	29 Aug 2003 00:20:22 -0000	1.1
  +++ utils.py	23 Sep 2003 23:16:20 -0000	1.2
  @@ -65,7 +65,6 @@
   import logging
   import types, StringIO
   
  -
   ###############################################################################
   # Base classes for the Displayable Objects
   ###############################################################################
  @@ -159,8 +158,12 @@
       return sorted   
     
   def printSeparator(indent=''):
  -    print indent + ' ---------------------------------------------------- Gumpy'
  +    printSeparatorToFile(None,indent)
       
  +def printSeparatorToFile(f=None,indent=''):    
  +    if not f: f = sys.stdout
  +    f.write( '%s\n' % (indent + ' ----------------------------------------------------
Gumpy'))
  +
   if __name__=='__main__':
   
     # init logging
  
  
  
  1.23      +34 -41    jakarta-gump/python/gump/document.py
  
  Index: document.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document.py,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- document.py	23 Sep 2003 15:13:08 -0000	1.22
  +++ document.py	23 Sep 2003 23:16:20 -0000	1.23
  @@ -316,10 +316,11 @@
       packages=getPackagedProjectContexts(context)
       if packages:
           startTableXDoc(x)
  -        x.write('      <tr><th>Name</th><th>Location</th></tr>')
  +        x.write('      <tr><th>Name</th><th>State</th><th>Location</th></tr>')
           for pctxt in packages:
               x.write('     <tr><!-- %s -->' % (pctxt.name))        
  -            x.write('      <td>%s</td>' % getContextLink(pctxt))   
  +            x.write('      <td>%s</td>' % getContextLink(pctxt,0))   
  +            x.write('      <td>%s</td>' % getContextStateDescription(pctxt))
               x.write('      <td>%s</td>' % pctxt.project.home)    
               x.write('     </tr>')
           endTableXDoc(x)
  @@ -446,6 +447,7 @@
       startSectionXDoc(x,'Details')
       startListXDoc(x)
       addItemXDoc(x,"Status: ", stateName(projectcontext.status))  
  +    addItemXDoc(x,"Module: ", getContextLink(projectcontext.parent))
       if projectcontext.cause and not projectcontext==projectcontext.cause:
           addItemXDoc(x,"Root Cause: ", getTypedContextLink(projectcontext.cause))
       addItemXDoc(x,"Elapsed: ", str(projectcontext.elapsedSecs()))
  @@ -461,39 +463,11 @@
           addItemXDoc(x,"Last Success: ", str(stats.last))
       endListXDoc(x)
       endSectionXDoc(x)
  -         
  -    if projectcontext.depends:
  -        startSectionXDoc(x,"Project Dependencies")
  -        startListXDoc(x)
  -        for depend in projectcontext.depends:
  -            addXItemXDoc(x,getContextLink(depend),getContextStateDescription(depend))
  -        endListXDoc(x)
  -        endSectionXDoc(x)
  -            
  -    if projectcontext.options:
  -        startSectionXDoc(x,"Optional Project Dependencies")
  -        startListXDoc(x)
  -        for option in projectcontext.options:
  -            addXItemXDoc(x,getContextLink(option),getContextStateDescription(option))
  -        endListXDoc(x)
  -        endSectionXDoc(x)
  -                      
  -    if projectcontext.dependees:
  -        startSectionXDoc(x,"Project Dependees")
  -        startListXDoc(x)
  -        for depend in projectcontext.dependees:
  -            addXItemXDoc(x,getContextLink(depend),getContextStateDescription(depend))
  -        endListXDoc(x)
  -        endSectionXDoc(x)
  -            
  -    if projectcontext.optionees:
  -        startSectionXDoc(x,"Optional Project Dependees")
  -        startListXDoc(x)
  -        for option in projectcontext.optionees:     
  -            addXItemXDoc(x,getContextLink(option),getContextStateDescription(option))
  -        endListXDoc(x)
  -        endSectionXDoc(x)
  -                  
  +    
  +    documentProjectContextList(x,"Project Dependencies",projectcontext.depends)    
  +    documentProjectContextList(x,"Optional Project Dependencies",projectcontext.options)
                     
  +    documentProjectContextList(x,"Project Dependees",projectcontext.dependees)        
   
  +    documentProjectContextList(x,"Optional Project Dependees",projectcontext.optionees)
                 
          
   #    x.write('<p><strong>Project Config :</strong> <link href=\'%s\'>XML</link></p>'
\
   #                % (getModuleProjectRelativeUrl(modulename,projectcontext.name)) )
  @@ -513,6 +487,19 @@
   #    footerXDoc(x)
   #    endXDoc(x)
   
  +def documentProjectContextList(x,title,projects):
  +  if projects:
  +        startSectionXDoc(x,title)
  +        startTableXDoc(x)
  +        x.write('      <tr><th>Name</th><th>Status</th></tr>')
  +        for pctxt in projects:
  +            startTableRowXDoc(x)    
  +            insertTableDataXDoc(x,getContextLink(pctxt))
  +            insertTableDataXDoc(x,getContextStateDescription(pctxt))
  +            endTableRowXDoc(x)
  +        endTableXDoc(x)
  +        endSectionXDoc(x)
  +            
   def documentAnnotations(x,annotations):
       if not annotations: return
       startSectionXDoc(x,'Annotations')
  @@ -561,7 +548,8 @@
           endListXDoc(x)
           
           if work.command.params:
  -            x.write('<table><tr><th>Parameters</th></tr><tr><th>Prefix</th><th>Name</th><th>Value</th></tr>')
  +            startSectionXDoc(x,'Parameter')    
  +            x.write('<table><tr><th>Prefix</th><th>Name</th><th>Value</th></tr>')
               for param in work.command.params.items():
                   x.write('<tr><td>')
                   if param.prefix: 
  @@ -576,9 +564,11 @@
                       x.write('N/A')
                   x.write('</td></tr>\n')        
               x.write('</table>\n')
  +            endSectionXDoc(x)
           
           if work.command.env:
  -            x.write('<table><tr><th>Environment</th></tr><tr><th>Name</th><th>Value</th></tr>')
  +            startSectionXDoc(x,'Environment Overrides')    
  +            x.write('<table><tr><th>Name</th><th>Value</th></tr>')
               for (name, value) in work.command.env.iteritems():
                   x.write('<tr><td>')
                   x.write(name)
  @@ -589,6 +579,7 @@
                       x.write('N/A')
                   x.write('</td></tr>\n')        
               x.write('</table>\n')
  +            endSectionXDoc(x)
           
           startSectionXDoc(x,'Command Line')
           sourceXDoc(x,work.command.formatCommandLine())
  @@ -893,7 +884,7 @@
       elif isinstance(context,ModuleContext):
           url=getModuleRelativeUrl(context.name,depth)
       else:        
  -        url=getModuleProjectRelativeUrl(context.parent.name,context.name,1)
  +        url=getModuleProjectRelativeUrl(context.parent.name,context.name,depth)
       return url
   
   def getTypedContextLink(context,depth=1):
  @@ -914,9 +905,11 @@
       
   def getContextStateDescription(context):
       xdoc=stateName(context.status)
  -    if not context.reason==REASON_UNSET: xdoc+='/'+reasonString(context.reason)
  -    if context.cause:
  +    if not context.reason==REASON_UNSET: xdoc+=' with reason '+reasonString(context.reason)
  +    if context.cause and not context.cause == context:
  +        xdoc+=", caused by "
           xdoc+=getContextLink(context.cause)
  +    return xdoc
   
   def getWorkspaceRelativeUrl(depth=0):
       return getUp(depth)+'index.html'
  @@ -1052,7 +1045,7 @@
       
   def addXItemXDoc(f,t,i=None):
       if i:
  -        f.write('      <li>%s - <strong>%s</strong></li>\n' % (t,
i))    
  +        f.write('      <li>%s - %s</li>\n' % (t, i))    
       else:
           f.write('      <li>%s</li>\n' % (t))
       
  
  
  
  1.12      +10 -4     jakarta-gump/python/gump/conf.py
  
  Index: conf.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/conf.py,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- conf.py	11 Sep 2003 21:11:42 -0000	1.11
  +++ conf.py	23 Sep 2003 23:16:20 -0000	1.12
  @@ -103,7 +103,13 @@
       prefix = "[GUMPY]"
       signature="\r\n--\r\nGump http://jakarta.apache.org/gump"
       
  -    version="2.0.1-alpha-0001"
  +    version="2.0.1-alpha-0002"
  +    
  +class switches:
  +    """Configuration of switches """    
  +    failtesting=0 # Not testing.. 
  +    debugging=0 # Not debugging..
  +    
   
   def basicConfig():
       if not os.path.exists(dir.cache): os.mkdir(dir.cache)
  
  
  
  1.1                  jakarta-gump/python/gump/tools.py
  
  Index: tools.py
  ===================================================================
  #!/usr/bin/env python
  
  # $Header: /home/cvspublic/jakarta-gump/python/gump/conf.py,v 1.7 2003/05/10 18:20:36 nicolaken
Exp $
  # $Revision: 1.7 $
  # $Date: 2003/05/10 18:20:36 $
  #
  # ====================================================================
  #
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2003 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution, if
  #    any, must include the following acknowlegement:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowlegement may appear in the software itself,
  #    if and wherever such third-party acknowlegements normally appear.
  #
  # 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
  #    Foundation" must not be used to endorse or promote products derived
  #    from this software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache"
  #    nor may "Apache" appear in their names without prior written
  #    permission of the Apache Group.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  
  """
      Helper Stuff
  """
  
  import logging
  import types, StringIO
  
  from gump import log
  from gump.launcher import *
  from gump.context import *
      
  def listDirectoryAsWork(context,directory,name=None):
      ok=0
      if not name: name='list_'+directory
      cmd=getCmdFromString("ls -l "+directory,name)
      try:
          result=execute(cmd)
          ok=result.status==CMD_STATUS_SUCCESS 
          if not ok:
              log.error('Failed to list [' + directory + ']')     
      except Exception, details:
          ok=0
          log.error('Failed to list [' + directory + '] : ' + str(details))
         
      # Update Context
      context.performedWork(CommandWorkItem(WORK_TYPE_DOCUMENT,cmd,result))
          
  if __name__=='__main__':
  
    # init logging
    logging.basicConfig()
  
    #set verbosity to show all messages of severity >= default.logLevel
    log.setLevel(default.logLevel)
    
    dump(log)
    
  
  
  

Mime
View raw message