You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by bo...@apache.org on 2009/02/16 05:54:29 UTC

svn commit: r744799 - in /gump/trunk/python/gump/core/update: cvs.py git.py scmupdater.py svn.py updater.py

Author: bodewig
Date: Mon Feb 16 04:54:28 2009
New Revision: 744799

URL: http://svn.apache.org/viewvc?rev=744799&view=rev
Log:
PyLint assisted import cleaning - and some methods are now functions

Modified:
    gump/trunk/python/gump/core/update/cvs.py
    gump/trunk/python/gump/core/update/git.py
    gump/trunk/python/gump/core/update/scmupdater.py
    gump/trunk/python/gump/core/update/svn.py
    gump/trunk/python/gump/core/update/updater.py

Modified: gump/trunk/python/gump/core/update/cvs.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/cvs.py?rev=744799&r1=744798&r2=744799&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/cvs.py (original)
+++ gump/trunk/python/gump/core/update/cvs.py Mon Feb 16 04:54:28 2009
@@ -15,49 +15,36 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""
-
-"""
-
-import os.path
-import sys
-from fnmatch import fnmatch
-
-from gump import log
-from gump.core.run.gumprun import *
-from gump.core.config import dir, default, basicConfig
-
-from gump.util import dump, display, getIndent, logResourceUtilization, \
-                            invokeGarbageCollection
-from gump.util.note import Annotatable
-from gump.util.work import *
-
-from gump.util.tools import *
-
-from gump.core.model.workspace import *
-from gump.core.model.module import Module
-from gump.core.model.project import Project
-from gump.core.model.depend import  ProjectDependency
-from gump.core.model.stats import *
-from gump.core.model.state import *
-
-from gump.tool.integration.cvs import *
-
+from gump.core.model.workspace import Cmd
 from gump.core.update.scmupdater import ScmUpdater
+from gump.tool.integration.cvs import readLogins, loginToRepositoryOnDemand
+
+def maybe_add_tag(module, cmd):
+    # Determine if a tag is set, on <cvs or on <module
+    tag = None
+    if module.getScm().hasTag():
+        tag = module.getScm().getTag()
+    elif module.hasTag():
+        tag = module.getTag()
+    if tag:
+        cmd.addParameter('-r', tag, ' ')
 
 ###############################################################################
 # Classes
 ###############################################################################
 
 class CvsUpdater(ScmUpdater):
+    """
+    Updater for CVS
+    """
     
-    def __init__(self,run):
-        ScmUpdater.__init__(self,run)
+    def __init__(self, run):
+        ScmUpdater.__init__(self, run)
 
         #
         # A stash of known logins.
         #
-        self.logins=readLogins()
+        self.logins = readLogins()
 
     def getCheckoutCommand(self, module):
         """
@@ -72,7 +59,7 @@
         # do a cvs checkout
         cmd.addParameter('checkout')
         cmd.addParameter('-P')
-        self.maybeAddTag(module, cmd)
+        maybe_add_tag(module, cmd)
 
         if not module.getScm().hasModule() or \
            not module.getScm().getModule() == module.getName(): 
@@ -100,7 +87,7 @@
         cmd.addParameter('update')
         cmd.addParameter('-P')
         cmd.addParameter('-d')
-        self.maybeAddTag(module, cmd)
+        maybe_add_tag(module, cmd)
 
         return cmd
     
@@ -122,12 +109,3 @@
         # Provide CVS logins, if not already there
         loginToRepositoryOnDemand(repository, root, self.logins)
 
-    def maybeAddTag(self, module, cmd):
-        # Determine if a tag is set, on <cvs or on <module
-        tag = None
-        if module.getScm().hasTag():
-            tag = module.getScm().getTag()
-        elif module.hasTag():
-            tag = module.getTag()
-        if tag:
-            cmd.addParameter('-r', tag, ' ')

Modified: gump/trunk/python/gump/core/update/git.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/git.py?rev=744799&r1=744798&r2=744799&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/git.py (original)
+++ gump/trunk/python/gump/core/update/git.py Mon Feb 16 04:54:28 2009
@@ -16,49 +16,35 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""
-
-"""
-
-import os.path
-import sys
-from fnmatch import fnmatch
-
 from gump import log
-from gump.core.run.gumprun import *
-from gump.core.config import dir, default, basicConfig
-
-from gump.util import dump, display, getIndent, logResourceUtilization, \
-                            invokeGarbageCollection
-from gump.util.note import Annotatable
-from gump.util.work import *
-
-from gump.util.tools import *
-
-from gump.core.model.workspace import *
-from gump.core.model.module import Module
-from gump.core.model.project import Project
-from gump.core.model.depend import  ProjectDependency
-from gump.core.model.stats import *
-from gump.core.model.state import *
-
+from gump.core.model.workspace import Cmd
 from gump.core.update.scmupdater import ScmUpdater
 
+def log_repository_and_url(module):
+    repository = module.repository
+    url = module.getScm().getRootUrl()
+    log.debug("GIT URL: [" + url + "] on Repository: " + \
+                  repository.getName())
+
+                  
 ###############################################################################
 # Classes
 ###############################################################################
 
 class GitUpdater(ScmUpdater):
+    """
+    Updater for GIT
+    """
     
-    def __init__(self,run):
-        ScmUpdater.__init__(self,run)
+    def __init__(self, run):
+        ScmUpdater.__init__(self, run)
 
 
     def getCheckoutCommand(self, module):
         """
             Build the appropriate GIT command for clone
         """
-        self.logRepositoryAndURL(module)
+        log_repository_and_url(module)
         cmd = Cmd('git-clone', 'update_' + module.getName(), 
                   module.getWorkspace().getSourceControlStagingDirectory())
         self.maybeMakeQuiet(module, cmd)
@@ -70,19 +56,12 @@
         """
             Build the appropriate GIT command for pull
         """
-        self.logRepositoryAndURL(module)
+        log_repository_and_url(module)
         cmd = Cmd('git-pull', 'update_' + module.getName(), 
                   module.getSourceControlStagingDirectory())
         self.maybeMakeQuiet(module, cmd)
         return cmd
 
-    def logRepositoryAndURL(self, module):
-        repository = module.repository
-        url = module.getScm().getRootUrl()
-        log.debug("GIT URL: [" + url + "] on Repository: " + \
-                      repository.getName())
-
     def maybeMakeQuiet(self, module, cmd):
         if self.shouldBeQuiet(module):    
             cmd.addParameter('--quiet')
-                  

Modified: gump/trunk/python/gump/core/update/scmupdater.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/scmupdater.py?rev=744799&r1=744798&r2=744799&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/scmupdater.py (original)
+++ gump/trunk/python/gump/core/update/scmupdater.py Mon Feb 16 04:54:28 2009
@@ -17,16 +17,12 @@
 # limitations under the License.
 
 import os.path
-import sys
 
 from gump import log
 
-from gump.core.run.gumprun import *
-from gump.util.note import Annotatable
-from gump.core.model.workspace import *
-from gump.core.model.module import Module
-from gump.core.model.stats import *
-from gump.core.model.state import *
+from gump.core.model.workspace import CommandWorkItem, execute, \
+    REASON_UPDATE_FAILED, STATE_FAILED, STATE_SUCCESS, WORK_TYPE_UPDATE
+from gump.core.run.gumprun import RunSpecific
 
 ###############################################################################
 # Classes
@@ -38,7 +34,7 @@
     Provides helpers and template method implementations.
     """
     
-    def __init__(self,run):
+    def __init__(self, run):
         RunSpecific.__init__(self, run)
 
     #
@@ -69,12 +65,13 @@
 
         if cmd:
             if isUpdate:
-                log.debug(module.getScm().getScmName() + " Module Update : " +\
+                log.debug(module.getScm().getScmName() + " Module Update : " + \
                               module.getName() + ", Repository Name: " + \
                               module.repository.getName())
             else:
-                log.debug(module.getScm().getScmName() + " Module Checkout : " +\
-                              module.getName() + ", Repository Name: " + \
+                log.debug(module.getScm().getScmName() + \
+                              " Module Checkout : " + module.getName() + \
+                              ", Repository Name: " + \
                               module.repository.getName())
 
             # Execute the command and capture results        
@@ -94,7 +91,8 @@
 
             return module.okToPerformWork()
 
-        log.error("Don't know how to to checkout/update module: " + module.name)   
+        log.error("Don't know how to to checkout/update module: " + \
+                      module.name)   
         module.changeState(STATE_FAILED, REASON_UPDATE_FAILED)
         return False
 

Modified: gump/trunk/python/gump/core/update/svn.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/svn.py?rev=744799&r1=744798&r2=744799&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/svn.py (original)
+++ gump/trunk/python/gump/core/update/svn.py Mon Feb 16 04:54:28 2009
@@ -16,32 +16,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""
-
-"""
-
-import os.path
-import sys
-from fnmatch import fnmatch
-
 from gump import log
-from gump.core.run.gumprun import *
-from gump.core.config import dir, default, basicConfig
-
-from gump.util import dump, display, getIndent, logResourceUtilization, \
-                            invokeGarbageCollection
-from gump.util.note import Annotatable
-from gump.util.work import *
-
-from gump.util.tools import *
-
-from gump.core.model.workspace import *
-from gump.core.model.module import Module
-from gump.core.model.project import Project
-from gump.core.model.depend import  ProjectDependency
-from gump.core.model.stats import *
-from gump.core.model.state import *
-
+from gump.core.model.workspace import Cmd
 from gump.core.update.scmupdater import ScmUpdater
 
 ###############################################################################
@@ -49,9 +25,12 @@
 ###############################################################################
 
 class SvnUpdater(ScmUpdater):
+    """
+    Updater for Subversion
+    """
     
-    def __init__(self,run):
-        ScmUpdater.__init__(self,run)
+    def __init__(self, run):
+        ScmUpdater.__init__(self, run)
 
 
     def getCheckoutCommand(self, module):
@@ -79,8 +58,8 @@
         #
         # Prepare SVN checkout/update command...
         # 
-        cmd=Cmd('svn', 'update_'+module.getName(), 
-                    module.getWorkspace().getSourceControlStagingDirectory())
+        cmd = Cmd('svn', 'update_'+module.getName(), 
+                  module.getWorkspace().getSourceControlStagingDirectory())
        
         #
         # Be 'quiet' (but not silent) unless requested otherwise.

Modified: gump/trunk/python/gump/core/update/updater.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/updater.py?rev=744799&r1=744798&r2=744799&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/updater.py (original)
+++ gump/trunk/python/gump/core/update/updater.py Mon Feb 16 04:54:28 2009
@@ -21,32 +21,70 @@
 """
 
 import os.path
-import sys
 
 from gump import log
-
-from gump.core.run.gumprun import *
-from gump.core.config import dir, default, basicConfig
-
+from gump.core.model.workspace import catFileToFileHolder, \
+    EXIT_CODE_FAILED, EXIT_CODE_SUCCESS, FILE_TYPE_LOG, \
+    gumpSafeName, logResourceUtilization, \
+    STATE_FAILED, STATE_SUCCESS, syncDirectories, REASON_SYNC_FAILED
+from gump.core.run.gumprun import RunSpecific
 from gump.core.update.cvs import CvsUpdater
-from gump.core.update.svn import SvnUpdater
-from gump.core.update.p4 import P4Updater
 from gump.core.update.git import GitUpdater
+from gump.core.update.p4 import P4Updater
+from gump.core.update.svn import SvnUpdater
+
+def syncModule(module):
+    """
+        
+        Synchronize the storage area with the build area
+            
+    """
+    workspace = module.getWorkspace()
+    
+    sourcedir = module.getSourceControlStagingDirectory() 
+    destdir = module.getWorkingDirectory()
+            
+    # Perform the sync...
+    try:
+        # Store changes next to updates log
+        changesFile = os.path.abspath(os.path.join(workspace.tmpdir,
+                                                   'changes_to_' + \
+                                                       gumpSafeName(module.getName()) + \
+                                                       '.txt'))
+                
+        # Perform the operation.
+        (actions, modified, cleaned) = syncDirectories(sourcedir, destdir, \
+                                                           module, \
+                                                           changesFile)
 
-from gump.util import dump, display, getIndent, logResourceUtilization, \
-                            invokeGarbageCollection
-from gump.util.note import Annotatable
-from gump.util.work import *
-
-from gump.util.tools import *
-
-from gump.core.model.workspace import *
-from gump.core.model.module import Module
-from gump.core.model.project import Project
-from gump.core.model.depend import  ProjectDependency
-from gump.core.model.stats import *
-from gump.core.model.state import *
+        # We are good to go...
+        module.changeState(STATE_SUCCESS)
+                
+        # Were the contents of the repository modified?
+        if modified: 
+        
+            #
+            # Use 'incoming changes' to note that the module
+            # was modified.
+            #
+            module.setModified(True)                                  
+            log.info('Update(s) received via on #[' \
+                            + `module.getPosition()` + \
+                            '] : ' + module.getName())
+                            
+                    
+    except Exception, details:
+        module.changeState(STATE_FAILED, REASON_SYNC_FAILED)
+        message = 'Synchronize Failed: ' + str(details)
+        module.addError(message)
+        log.error(message, exc_info=1)
+        
+        
+    # Might help even with sync failures.
+    if os.path.exists(changesFile):
+        catFileToFileHolder(module, changesFile, FILE_TYPE_LOG)
 
+    return module.okToPerformWork()
 
 ###############################################################################
 # Classes
@@ -54,34 +92,30 @@
 
 class GumpUpdater(RunSpecific):
     
-    def __init__(self,run):
+    def __init__(self, run):
         RunSpecific.__init__(self, run)
         
         self.updaters = {'cvs' : CvsUpdater(run), 'svn' : SvnUpdater(run),
                          'p4' : P4Updater(run), 'git' : GitUpdater(run)}
 
 
-    """
-    
-        ******************************************************************
-        
-            THE UPDATE INTERFACE
-        
-        ******************************************************************
-    
-    """
+    #    ******************************************************************
+    #    
+    #        THE UPDATE INTERFACE
+    #    
+    #    ******************************************************************
     def update(self):        
         logResourceUtilization('Before update')
         
         #
         # Doing a full build?
         #
-        all=not self.run.getOptions().isQuick()
+        all = not self.run.getOptions().isQuick()
         
         if all:
-            modules=self.run.getGumpSet().getModuleSequence()
+            modules = self.run.getGumpSet().getModuleSequence()
         else:
-            modules=self.run.getGumpSet().getModules()
+            modules = self.run.getGumpSet().getModules()
         
         #
         # Checkout from source code repositories
@@ -108,7 +142,7 @@
         for module in list: 
             self.updateModule(module)
         
-    def updateModule(self,module):
+    def updateModule(self, module):
     
     #        if module.isPackaged(): 
     #            # Not sure we have anything to do right now
@@ -133,7 +167,7 @@
                    
             # Synchronize the files...
             if ok:
-                self.syncModule(module)     
+                syncModule(module)     
                     
     
     def getScmUpdater(self, module):
@@ -145,60 +179,7 @@
             return self.updaters.get(scm.getScmType())
         return None
 
-    def syncModule(self,module):
-        """
-            
-            Synchronize the storage area with the build area
-                
-        """
-        workspace = module.getWorkspace()
-        
-        sourcedir = module.getSourceControlStagingDirectory() 
-        destdir = module.getWorkingDirectory()
-                
-        # Perform the sync...
-        try:
-            # Store changes next to updates log
-            changesFile = os.path.abspath(os.path.join(workspace.tmpdir,
-                                                       'changes_to_' + \
-                                                           gumpSafeName(module.getName()) + \
-                                                           '.txt'))
-                    
-            # Perform the operation.
-            (actions,modified,cleaned)=syncDirectories(sourcedir,destdir,module,
-                                                       changesFile)
-                    
-            # We are good to go...
-            module.changeState(STATE_SUCCESS)
-                    
-            # Were the contents of the repository modified?
-            if modified: 
-            
-                #
-                # Use 'incoming changes' to note that the module
-                # was modified.
-                #
-                module.setModified(True)                                  
-                log.info('Update(s) received via on #[' \
-                                + `module.getPosition()` + \
-                                '] : ' + module.getName())
-                                
-                        
-        except Exception, details:
-            module.changeState(STATE_FAILED,REASON_SYNC_FAILED)
-            message='Synchronize Failed: ' + str(details)
-            module.addError(message)
-            log.error(message, exc_info=1)
-            
-            
-        # Might help even with sync failures.
-        if os.path.exists(changesFile):
-            catFileToFileHolder(module, changesFile, FILE_TYPE_LOG)
-
-        return module.okToPerformWork()
-        
-
-    def preview(self,module):
+    def preview(self, module):
         """
         
             Preview what ought occur for this