ajack       2003/09/26 12:09:52

  Modified:    python/gump update.py __init__.py context.py tools.py
                        build.py logic.py xmlutils.py document.py
  Log:
  1) More documentation outputs (start date/time, TZ)
  2) Moved .cvspass access to separate methods, to allow testing
  3) Added log messages to (2)
  4) Hacked '/1 ' at start of .cvspass lines (copying what I find in one cvs created, 
can't find a spec)
  5) Attempted to cope with XML syntax errors in descriptors [logs, but doubt it is 
complete]
  
  Revision  Changes    Path
  1.12      +44 -20    jakarta-gump/python/gump/update.py
  
  Index: update.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/update.py,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- update.py 25 Sep 2003 17:04:52 -0000      1.11
  +++ update.py 26 Sep 2003 19:09:52 -0000      1.12
  @@ -101,23 +101,43 @@
     modules = 
getModulesForProjectList(getBuildSequenceForProjects(getProjectsForProjectExpression(expr)))
         
     return updateModules(workspace,modules,context)
  -  
  -def updateModules(workspace, modules, context=GumpContext()):
  -    
  +
  +def readLogins():
     # read the list of cvs repositories that the user is already logged into
  -  password={}
  +  logins={}
     cvspassfile=os.path.expanduser(os.path.join('~','.cvspass'))
     try:
       cvspass=open(cvspassfile)
       for line in cvspass.readlines():
  -      password.update(dict([line.strip().split(' ',1)]))
  +      logins.update(dict([line.strip().split(' ',1)]))
       cvspass.close()
  -  except:
  -    pass
  +  
  +  except Exception, detail:
  +    log.error('Failed to read ~/.cvspass. Details: ' + str(detail))
  +    
  +  return logins
  + 
  +def loginToRepositoryOnDemand(repository,root,logins):
  +    # log into the cvs repository
  +    if repository.root.method=='pserver':
  +        newpass=mangle(repository.root.password)
  +        if not root in logins or logins[root]<>newpass:
  +            log.info('Provide login for CVS repository: ' + repository.name + ' @ ' 
+ root)            
  +            # Open with append...
  +            try:
  +                cvspassfile=os.path.expanduser(os.path.join('~','.cvspass'),'a')
  +                cvspassfile.write('/1 '+root+' '+newpass+'\n')
  +                cvspassfile.close()
  +            except Exception, detail:
  +                log.error('Failed to append to ~/.cvspass. Details: ' + str(detail))
  +                
  +def updateModules(workspace, modules, context=GumpContext()):
    
     os.chdir(workspace.cvsdir)
     log.debug("Workspace CVS Directory: " + workspace.cvsdir)
   
  +  logins=readLogins()
  +
     log.info('Modules to update:') 
       
     # Update all the modules that have CVS repositories
  @@ -139,14 +159,14 @@
         
             log.info("CVS Root " + module.cvsroot() + " Repository: " + 
str(repository))
         
  -          # log into the cvs repository
  -          if repository.root.method=='pserver':
  -            newpass=mangle(repository.root.password)
  -            if not root in password or password[root]<>newpass:
  -              cvspassfile=os.path.expanduser(os.path.join('~','.cvspass'),'a')
  -              cvspassfile.write(root+' '+newpass+'\n')
  -              cvspassfile.close()
  -
  +          #
  +          # Provide logins, if not already there
  +          #
  +          loginToRepositoryOnDemand(repository,root,logins)
  +
  +          #
  +          # Prepare CVS checkout/update command...
  +          # 
             cmd=Cmd('cvs','update_'+name,workspace.cvsdir)
             cmd.addParameter('-z3')
             cmd.addParameter('-d', root)
  @@ -216,6 +236,10 @@
     
     context=GumpContext()
     
  -  update(workspace, ps, context)
  +  logins=readLogins()
  +  
  +  dump(logins)
  +  
  +  # update(workspace, ps, context)
     
  -  dump(context)
  +  # dump(context)
  
  
  
  1.12      +4 -4      jakarta-gump/python/gump/__init__.py
  
  Index: __init__.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/__init__.py,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- __init__.py       29 Aug 2003 00:20:22 -0000      1.11
  +++ __init__.py       26 Sep 2003 19:09:52 -0000      1.12
  @@ -105,7 +105,7 @@
   # tell python what modules make up the gump package
   __all__ = ["conf", "launcher", "view", "build", "gen", "check", "update", 
                        "model", "xmlutils", "rss", "login", "xdoc", "statistics",
  -                     "document"]
  +                     "document","tools"]
   
   
   # ensure dirs exists
  
  
  
  1.11      +7 -1      jakarta-gump/python/gump/context.py
  
  Index: context.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/context.py,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- context.py        25 Sep 2003 19:33:49 -0000      1.10
  +++ context.py        26 Sep 2003 19:09:52 -0000      1.11
  @@ -62,6 +62,7 @@
       This module contains information on
   """
   
  +from time import localtime, strftime, tzname
   from string import lower, capitalize
   
   from gump import log
  @@ -93,7 +94,7 @@
               "Success" : STATUS_SUCCESS,
               "Failed" : STATUS_FAILED,
               "Prerequisite Failed" : STATUS_PREREQ_FAILURE,
  -            "Complete. Perform No Action"  : STATUS_COMPLETE}
  +            "Complete"  : STATUS_COMPLETE}
              
   def stateForName(name):
       return describedState.get(name,STATUS_UNSET)
  @@ -660,6 +661,11 @@
           # Turns on ant '-debug'
           #
           self.debug=0 
  +        
  +        #    
  +        self.startdatetime=time.strftime("%a, %d %b %Y %H:%M:%S (%Z)", \
  +                                time.localtime())
  +        self.timezone=str(time.tzname)
           
       def performedWorkOnProject(self,project,item):
           (mctxt,pctxt)=self.getContextsForProject(project)
  
  
  
  1.2       +30 -1     jakarta-gump/python/gump/tools.py
  
  Index: tools.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/tools.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- tools.py  23 Sep 2003 23:16:20 -0000      1.1
  +++ tools.py  26 Sep 2003 19:09:52 -0000      1.2
  @@ -84,7 +84,36 @@
          
       # Update Context
       context.performedWork(CommandWorkItem(WORK_TYPE_DOCUMENT,cmd,result))
  -        
  +       
  +
  +   
  +def syncDirectories(context,workspace,type,cwd,sourcedir,destdir,name=None):        
        
  +    # :TODO: Make this configurable (once again)
  +    #if not workspace.sync:
  +    #  workspace.sync = default.syncCommand
  +    
  +    if context.noRSync:
  +        cmd=Cmd('cp','sync_'+module.name,dir.work)
  +        cmd.addParameter('-Rf')
  +        cmd.addParameter(sourcedir)
  +        cmd.addParameter(destdir)
  +    else:
  +        cmd=Cmd('rsync','rsync_'+module.name,dir.work)            
  +        cmd.addParameter('-r')
  +        cmd.addParameter('-a')
  +        cmd.addParameter('--delete')
  +        cmd.addParameter(sourcedir)
  +        cmd.addParameter(destdir)
  +
  +    log.debug(' ------ Sync\'ing : '+ module.name)
  +    
  +    # Perform the Sync
  +    cmdResult=execute(cmd,workspace.tmpdir)
  +
  +    work=CommandWorkItem(type,cmd,cmdResult)
  +    
  +    return work        
  +    
   if __name__=='__main__':
   
     # init logging
  
  
  
  1.14      +5 -26     jakarta-gump/python/gump/build.py
  
  Index: build.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/build.py,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- build.py  25 Sep 2003 17:04:52 -0000      1.13
  +++ build.py  26 Sep 2003 19:09:52 -0000      1.14
  @@ -154,29 +154,8 @@
           sourcedir = os.path.abspath(os.path.join(workspace.cvsdir,module.name)) # 
todo allow override
           destdir = os.path.abspath(workspace.basedir)
           
  -        # :TODO: Make this configurable (once again)
  -        #if not workspace.sync:
  -        #  workspace.sync = default.syncCommand
  -    
  -        if context.noRSync:
  -            cmd=Cmd('cp','sync_'+module.name,dir.work)
  -            cmd.addParameter('-Rf')
  -            cmd.addParameter(sourcedir)
  -            cmd.addParameter(destdir)
  -        else:
  -            cmd=Cmd('rsync','rsync_'+module.name,dir.work)            
  -            cmd.addParameter('-r')
  -            cmd.addParameter('-a')
  -            cmd.addParameter('--delete')
  -            cmd.addParameter(sourcedir)
  -            cmd.addParameter(destdir)
  -
  -        log.debug(' ------ Sync\'ing : '+ module.name)
  -    
  -        # Perform the Sync
  -        cmdResult=execute(cmd,workspace.tmpdir)
  -
  -        work=CommandWorkItem(WORK_TYPE_SYNC,cmd,cmdResult)
  +        
work=syncDirectories(context,workspace,WORK_TYPE_SYNC,dir.work,sourcedir,destdir,module.name)
  +        
           mctxt.performedWork(work)
   
           # Update Context w/ Results  
  
  
  
  1.6       +1 -1      jakarta-gump/python/gump/logic.py
  
  Index: logic.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/logic.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- logic.py  25 Sep 2003 17:04:52 -0000      1.5
  +++ logic.py  26 Sep 2003 19:09:52 -0000      1.6
  @@ -339,7 +339,7 @@
           message='Workspace version ['+workspace.version+'] below expected [' + 
setting.ws_version + ']'
           context.addWarning(message)
           log.warning(message)   
  -   
  +        
       #
       # Check each project...
       #
  
  
  
  1.2       +4 -1      jakarta-gump/python/gump/xmlutils.py
  
  Index: xmlutils.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/xmlutils.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- xmlutils.py       29 Aug 2003 00:20:22 -0000      1.1
  +++ xmlutils.py       26 Sep 2003 19:09:52 -0000      1.2
  @@ -209,7 +209,10 @@
         newHref=gumpCache(href)
         if newHref:
           log.debug('opening: ' + newHref + '\n')
  -        element=SAXDispatcher(open(newHref),cls.__name__.lower(),cls).docElement
  +        try:
  +            
element=SAXDispatcher(open(newHref),cls.__name__.lower(),cls).docElement        
  +        except Exception, detail:
  +            log.error('Failed to parse [' + newHref + ']. Details: ' + str(detail)) 
   
         else:
           # :TODO: Set any object "invalid"?
           log.warn("href:"+newHref+" not loaded")
  
  
  
  1.42      +30 -11    jakarta-gump/python/gump/document.py
  
  Index: document.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document.py,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- document.py       25 Sep 2003 21:59:55 -0000      1.41
  +++ document.py       26 Sep 2003 19:09:52 -0000      1.42
  @@ -260,6 +260,7 @@
       titledDataInTableXDoc(x,'Gump Preferred Workspace Version', setting.ws_version)
       titledDataInTableXDoc(x,'Java Command', context.javaCommand)
       titledDataInTableXDoc(x,'@@DATE@@', str(default.date))
  +    titledDataInTableXDoc(x,'Start Date/Time', workspace.startdatetime)
       
       endTableXDoc(x)
       endSectionXDoc(x)                
  @@ -384,13 +385,19 @@
       x=startXDoc(getModuleDocument(workspace,modulename,mdir))
       headerXDoc(x,'Module : ' + modulename)
       
  -    if module.description or module.url:
  -        startSectionXDoc(x,'Description')     
  -        if module.description:
  -            paragraphXDoc(x,module.description)
  -        if module.url:
  -            paragraphXDoc(x,getLink(module.url))
  -        endSectionXDoc(x)
  +    
  +    # Provide a description/link back to the module site.
  +    startSectionXDoc(x,'Description') 
  +    description=str(module.description)    
  +    if not description:
  +        description='No description provided.'        
  +    if str(module.url):
  +        description+=' For more information, see: ' + getLink(str(module.url))
  +    else:
  +        description+=' No module URL provided.'
  +            
  +    paragraphXDoc(x,description)
  +    endSectionXDoc(x)
       
           
       documentAnnotations(x,modulecontext.annotations)
  @@ -398,7 +405,7 @@
       startSectionXDoc(x,'Projects')
       x.write('    <table>\n')
       x.write('     <tr>')        
  -    x.write('      <th>Name</th><th>State</th><th>Reason</th><th>Elapsed Time</th>')
  +    x.write('      <th>Name</th><th>State</th><th>Elapsed Time</th>')
       x.write('     </tr>')
       pcount=0
       for pctxt in modulecontext:     
  @@ -407,8 +414,8 @@
           pcount+=1
           
           x.write('     <tr><!-- %s -->' % (pname))        
  -        x.write('      <td><link href=\'%s\'>%s</link></td><td>%s</td><td>%s</td>' 
% \
  -          
(getProjectRelativeUrl(pname),pname,stateName(pctxt.status),reasonString(pctxt.reason)))
    
  +        x.write('      <td><link href=\'%s\'>%s</link></td><td>%s</td>' % \
  +          
(getProjectRelativeUrl(pname),pname,getStatePairIcon(pctxt.getStatePair(),1)))    
           x.write('      <td>%s</td>' % elapsedTimeToString(pctxt.elapsedTime()))    
           x.write('     </tr>')
           
  @@ -453,7 +460,19 @@
       x=startXDoc(getProjectDocument(workspace,modulename,projectname,mdir))
       headerXDoc(x,'Project : ' + projectname)
      
  -    description=project.description or module.description
  +     
  +    # Provide a description/link back to the module site.
  +    startSectionXDoc(x,'Description') 
  +    description=str(project.description) or str(module.description)
  +    if not description:
  +        description='No description provided.'        
  +    if str(project.url):
  +        description+=' For more information, see: ' + getLink(str(project.url))
  +    else:        
  +        description='No project URL provided.'   
  +            
  +    paragraphXDoc(x,description)
  +    endSectionXDoc(x)
       if description:
           startSectionXDoc(x,'Description')     
           paragraphXDoc(x,description)
  
  
  

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

Reply via email to