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 2010/08/25 06:42:10 UTC

svn commit: r988801 - in /gump/trunk/python/gump/core: run/options.py runner/runner.py

Author: bodewig
Date: Wed Aug 25 04:42:10 2010
New Revision: 988801

URL: http://svn.apache.org/viewvc?rev=988801&view=rev
Log:
pylint

Modified:
    gump/trunk/python/gump/core/run/options.py
    gump/trunk/python/gump/core/runner/runner.py

Modified: gump/trunk/python/gump/core/run/options.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/run/options.py?rev=988801&r1=988800&r2=988801&view=diff
==============================================================================
--- gump/trunk/python/gump/core/run/options.py (original)
+++ gump/trunk/python/gump/core/run/options.py Wed Aug 25 04:42:10 2010
@@ -11,7 +11,7 @@
 #     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,
+# 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.
@@ -22,60 +22,51 @@
  
 """
 
-import os.path
-import os
-import sys
-import fnmatch
-
-from gump import log
-from gump.core.config import dir, default, basicConfig
-from gump.core.run.gumpenv import GumpEnvironment
-
-import gump.util
-import gump.util.work
-import gump.util.note
-
-from gump.core.model.workspace import Workspace
-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.state import *
-    
 ###############################################################################
 # Init
 ###############################################################################
 
 # Overall objectives
-OBJECTIVE_UNSET=0
-OBJECTIVE_UPDATE=0x01
-OBJECTIVE_BUILD=0x02
-OBJECTIVE_CHECK=0x04
-OBJECTIVE_DOCUMENT=0x08
+OBJECTIVE_UNSET = 0
+OBJECTIVE_UPDATE = 0x01
+OBJECTIVE_BUILD = 0x02
+OBJECTIVE_CHECK = 0x04
+OBJECTIVE_DOCUMENT = 0x08
 
-OBJECTIVE_REDO=OBJECTIVE_UPDATE | OBJECTIVE_BUILD
-OBJECTIVE_INTEGRATE=OBJECTIVE_UPDATE | OBJECTIVE_BUILD | \
+OBJECTIVE_REDO = OBJECTIVE_UPDATE | OBJECTIVE_BUILD
+OBJECTIVE_INTEGRATE = OBJECTIVE_UPDATE | OBJECTIVE_BUILD | \
                         OBJECTIVE_DOCUMENT
-OBJECTIVE_OFFLINE=OBJECTIVE_BUILD | OBJECTIVE_DOCUMENT
+OBJECTIVE_OFFLINE = OBJECTIVE_BUILD | OBJECTIVE_DOCUMENT
+
+# Features
+FEATURE_UNSET = 0
+FEATURE_STATISTICS = 0x01
+FEATURE_RESULTS = 0x02
+FEATURE_NOTIFY = 0x04
+FEATURE_DIAGRAM = 0x08
+FEATURE_SYNDICATE = 0x10
+FEATURE_DESCRIBE = 0x20
+FEATURE_PUBLISH = 0x40
+FEATURE_DOCUMENT = 0x80
+FEATURE_HISTORICAL = 0x80
+
+FEATURE_DEFAULT = FEATURE_STATISTICS \
+    | FEATURE_SYNDICATE \
+    | FEATURE_DESCRIBE \
+    | FEATURE_DOCUMENT \
+    | FEATURE_NOTIFY
+
+FEATURE_ALL = FEATURE_STATISTICS \
+    | FEATURE_RESULTS \
+    | FEATURE_NOTIFY \
+    | FEATURE_DIAGRAM \
+    | FEATURE_SYNDICATE \
+    | FEATURE_DESCRIBE \
+    | FEATURE_PUBLISH \
+    | FEATURE_DOCUMENT
+
+FEATURE_OFFICIAL = FEATURE_ALL
 
-# Features            
-FEATURE_UNSET=0
-FEATURE_STATISTICS=0x01
-FEATURE_RESULTS=0x02
-FEATURE_NOTIFY=0x04
-FEATURE_DIAGRAM=0x08
-FEATURE_SYNDICATE=0x10
-FEATURE_DESCRIBE=0x20
-FEATURE_PUBLISH=0x40
-FEATURE_DOCUMENT=0x80
-FEATURE_HISTORICAL=0x80
-
-FEATURE_DEFAULT=FEATURE_STATISTICS|FEATURE_SYNDICATE|FEATURE_DESCRIBE|FEATURE_DOCUMENT|FEATURE_NOTIFY
-            
-FEATURE_ALL=FEATURE_STATISTICS|FEATURE_RESULTS|FEATURE_NOTIFY|FEATURE_DIAGRAM|    \
-                FEATURE_SYNDICATE|FEATURE_DESCRIBE|FEATURE_PUBLISH|FEATURE_DOCUMENT
-            
-FEATURE_OFFICIAL=FEATURE_ALL
-            
 
 ###############################################################################
 # Classes
@@ -83,185 +74,189 @@ FEATURE_OFFICIAL=FEATURE_ALL
 
 class GumpRunOptions:
     """
-    
+
     GumpRunOptions are the 'switches' that dictate the code path
-    
+
     """
     def __init__(self):
  
-        self.debug=False	
-        self.verbose=False	
-        self.cache=True	# Defaults to CACHE
-        self.quick=True	# Defaults to QUICK
-        self.dated=False	# Defaults to NOT dated.
-        self.optimize=False	# Do the least ammount of work...
-        self.official=False	# Do a full run (with publishing e-mail)
-        self.historical=False # Historical Database
-        
+        self.debug = False
+        self.verbose = False
+        self.cache = True # Defaults to CACHE
+        self.quick = True # Defaults to QUICK
+        self.dated = False        # Defaults to NOT dated.
+        self.optimize = False     # Do the least ammount of work...
+        self.official = False     # Do a full run (with publishing e-mail)
+        self.historical = False # Historical Database
+
         # Default is XDOCS/XHTML, but can also force text with --text 
-        self.text=False        
-        
+        self.text = False
+
         # Defautl for XDOCS is XHTML
-        self.xdocs=False
-        
-        self.objectives=OBJECTIVE_INTEGRATE
-        self.features=FEATURE_DEFAULT
-        
+        self.xdocs = False
+
+        self.objectives = OBJECTIVE_INTEGRATE
+        self.features = FEATURE_DEFAULT
+
+        self.resolver = None
+
     def isDated(self):
         return self.dated
-        
-    def setDated(self,dated):
-        self.dated=dated        
-        
+
+    def setDated(self, dated):
+        self.dated = dated
+
     def isHistorical(self):
         return self.historical
-        
-    def setHistorical(self,historical):
-        self.historical=historical
-        
+
+    def setHistorical(self, historical):
+        self.historical = historical
+
     def isOfficial(self):
         """
         Is an official run requested?
         """
         return self.official
-        
-    def setOfficial(self,official):
+
+    def setOfficial(self, official):
         """
         An official run
         """
-        self.official=official
-        self.features=FEATURE_OFFICIAL
-        
+        self.official = official
+        self.features = FEATURE_OFFICIAL
+
     def isQuick(self):
         """
         Is a 'quick' (not complete, i.e. list not sequence) run requested?
         """
         return self.quick
-        
-    def setQuick(self,quick):
+
+    def setQuick(self, quick):
         """
         Set a 'quick' (not complete, i.e. list not sequence) run request
-        """    
-        self.quick=quick
-        
+        """
+        self.quick = quick
+
     def isText(self):
         """
         Is Text documentation generation requested?
         """
         return self.text
-        
-    def setText(self,text):
-        self.text=text
-        
+
+    def setText(self, text):
+        self.text = text
+
     def isXDocs(self):
         """
         Is XDOC documentation generation requested?
         """
         return self.xdocs
-        
-    def setXDocs(self,xdocs):
+
+    def setXDocs(self, xdocs):
         """
         Set XDOC documentation generation
         """
-        self.xdocs=xdocs
-        
+        self.xdocs = xdocs
+
     def isCache(self):
         """
         Is metadata caching requested?
         """
         return self.cache
-        
-    def setCache(self,cache):
+
+    def setCache(self, cache):
         """
         Perform metadata caching
         """
-        self.cache=cache
-        
+        self.cache = cache
+
     def isDebug(self):
         """
         Is a debug run requested?
         """
         return self.debug
-        
-    def setDebug(self,debug):
-        self.debug=debug
-        
+
+    def setDebug(self, debug):
+        self.debug = debug
+
     def isVerbose(self):
         return self.verbose
-        
-    def setVerbose(self,verbose):
+
+    def setVerbose(self, verbose):
         """
         A verbose run
         """
-        self.verbose=verbose
+        self.verbose = verbose
 
-    def setResolver(self,resolver):
+    def setResolver(self, resolver):
         """
         The File/URL resolver (from Gump objects)
         """
-        self.resolver=resolver        
+        self.resolver = resolver
 
     def getResolver(self):
         return self.resolver
-        
+
     # Objectives...
-    def setObjectives(self,objectives):
+    def setObjectives(self, objectives):
         """
         Set the objectives
         """
-        self.objectives=objectives
-        
+        self.objectives = objectives
+
     def getObjectives(self):
         return self.objectives
-        
-    def _testObjectiveIsSet(self,objective):
+
+    def _testObjectiveIsSet(self, objective):
         """
         Helper to test a single objective
         """
-        if (self.objectives & objective): return True
+        if (self.objectives & objective):
+            return True
         return False
-        
+
     # Features...
-    def setFeatures(self,features):
+    def setFeatures(self, features):
         """
         Set the features
         """
-        self.features=features
-        
+        self.features = features
+
     def getFeatures(self):
         return self.features
-        
-    def disableFeature(self,feature):        
+
+    def disableFeature(self, feature):
         """
         Disable a specific feature (or bitwise or of features)
-        """    
+        """
         self.features = (self.features ^ feature)
-        
-    def enableFeature(self,feature):
+
+    def enableFeature(self, feature):
         """
         Enable a specific feature (or bitwise or of features)
         """
         self.features = (self.features | feature)
-        
-    def _testFeatureIsSet(self,feature):
+
+    def _testFeatureIsSet(self, feature):
         """
         A utility method to see if a feature is set.
         """
-        if (self.features & feature): return True
+        if (self.features & feature):
+            return True
         return False
-        
+
     def isUpdate(self):
         """
         Are Updates (CVS|SVN|...) to be performed?
         """
-        return self._testObjectiveIsSet(OBJECTIVE_UPDATE)        
-        
+        return self._testObjectiveIsSet(OBJECTIVE_UPDATE)
+
     def isBuild(self):
         """
         Are Builds (Ant|...) to be performed?
         """
         return self._testObjectiveIsSet(OBJECTIVE_BUILD)
-              
+
     def isCheck(self): 
         """
         Is this really jsut a 'check' or things?
@@ -290,7 +285,7 @@ class GumpRunOptions:
         """
         Is documentation to be created for this run?
         """
-        
+
     def isDocument(self):
         return  self._testObjectiveIsSet(OBJECTIVE_DOCUMENT) and \
                 self._testFeatureIsSet(FEATURE_DOCUMENT)

Modified: gump/trunk/python/gump/core/runner/runner.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/runner/runner.py?rev=988801&r1=988800&r2=988801&view=diff
==============================================================================
--- gump/trunk/python/gump/core/runner/runner.py (original)
+++ gump/trunk/python/gump/core/runner/runner.py Wed Aug 25 04:42:10 2010
@@ -41,9 +41,9 @@ from gump.actor.mvnrepoproxy.proxycontro
 class GumpRunner(RunSpecific):
     """
     Base class for other runners that initializes several helper objects.
-    
+
     the lifecycle for this class is as follows:
-    
+
         runner.initialize() # set up environment
         runner.perform()    # delegates to subclass to perform actual work
         runner.finalize()   # do some cleanup work
@@ -51,119 +51,119 @@ class GumpRunner(RunSpecific):
 
     def __init__(self, run, log=None):
         RunSpecific.__init__(self, run)
-        
+
         if not log: from gump import log
         self.log = log
-        
-        # Main players (soon we ought make them into actors, like the others).         
+
+        # Main players (soon we ought make them into actors, like the others).
         self.updater = GumpUpdater(run)
         self.builder = GumpBuilder(run)
-        
+
         # A helper per language/type
         self.java = gump.core.language.java.JavaHelper(run)
         self.csharp = gump.core.language.csharp.CSharpHelper(run)
-        
+
         # Stash them for reference...
         run.setUpdater(self.updater)
         run.setBuilder(self.builder)
-            
-        run.addLanguageHelper(Project.JAVA_LANGUAGE,self.java)  
+
+        run.addLanguageHelper(Project.JAVA_LANGUAGE,self.java)
         run.addLanguageHelper(Project.CSHARP_LANGUAGE,self.csharp)
-        
+
     def initialize(self,exitOnError=True):
         """
         Set up all of the neccessary resources for the subclass implementation to use.
         Besides modifying the properties of this class, we also modify bits of the
         workspace and bits of the GumpRun instance.
-        
+
         TODO: currently this method must be called from the performRun() method of the
         subclass. Call it from perform() instead.
-        
+
         TODO: clean this up and have a clear responsibility split between the various
         parts we're modifying here...
         """
-        
+
         logResourceUtilization('Before initialize')
-        
+
         # Perform start-up logic 
         workspace = self.run.getWorkspace()
-                
+
         # Check out environment
         if not self.run.getOptions().isQuick():
-            logResourceUtilization('Before check environment')            
+            logResourceUtilization('Before check environment')
             self.run.getEnvironment().checkEnvironment(exitOnError)
             logResourceUtilization('After check environment')
-        
+
         # Now, force cetain things (like blanking CLASSPATH)
         self.run.getEnvironment().setEnvironment()
-        
+
         # Modify the log location on the fly, if --dated
         if self.run.getOptions().isDated():
-            workspace.setDatedDirectories()     
-                    
+            workspace.setDatedDirectories()
+
         # Check the workspace
         if not workspace.getVersion() >= setting.WS_VERSION:
             message='Workspace version ['+str(workspace.getVersion())+'] below preferred [' + setting.WS_VERSION + ']'
             workspace.addWarning(message)
-            self.log.warn(message)   
+            self.log.warn(message)
 
         if not workspace.getVersion() >= setting.WS_MINIMUM_VERSION:
             message='Workspace version ['+str(workspace.getVersion())+'] below minimum [' + setting.WS_MINIMUM_VERSION + ']'
             workspace.addError(message)
-            self.log.error(message)   
-            
-        # Write workspace to a 'merge' file        
+            self.log.error(message)
+
+        # Write workspace to a 'merge' file
         if not self.run.getOptions().isQuick():
             workspace.writeXmlToFile(default.merge)
             workspace.setMergeFile(default.merge)
-                 
+
         # :TODO: Put this somewhere else, and/or make it depend upon something...
         workspace.changeState(STATE_SUCCESS)
  
         # Initialize Actors
-        self.initializeActors()             
+        self.initializeActors()
  
         # Let's get going...
         self.run._dispatchEvent(InitializeRunEvent(self.run))
-    
+
     def initializeActors(self):
         """
         Populate the GumpRun instance with the various actors.
-        
+
         The actors handle all the "optional" behaviour like writing HTML or sending e-mail. One
         way to think of this method is where we configure the "glue" between all the different
         bits and pieces of the application.
-        
+
         TODO:
         """
-        
+
         # Stamp times
         self.run.registerActor(TimeKeeper(self.run))
-        
+
         # Update statistics
         self.run.registerActor(Statistician(self.run))
-        
+
         # Load/Generate results (if we are in a multi-server)
         # environment, where result sharing is important
         if self.run.getOptions().isResults() and \
             self.run.getWorkspace().hasMultiplePythonServers():
-            self.run.registerActor(Resulter(self.run))            
+            self.run.registerActor(Resulter(self.run))
 
         # Add Database storer
         if self.run.getOptions().isOfficial() and \
             self.run.getWorkspace().hasDatabaseInformation() and \
-            not self.run.getOptions().isHistorical():    
+            not self.run.getOptions().isHistorical():
             try:
                 import gump.actor.mysql.databaser
                 self.run.registerActor(gump.actor.mysql.databaser.Databaser(self.run))
             except Exception, details:
                 self.log.warning('Unable to register Database Actor :  %s ' % details,
                             exc_info=1)
-        
+
         # Add Historical Database storer -- ??? no such thing...
         if self.run.getOptions().isOfficial() and \
             self.run.getWorkspace().hasDatabaseInformation() and \
-            self.run.getOptions().isHistorical():       
+            self.run.getOptions().isHistorical():
             try:
                 import gump.actor.history.historical
                 self.run.registerActor(gump.actor.history.historical.Historical(self.run))
@@ -181,7 +181,7 @@ class GumpRunner(RunSpecific):
             # now create the Dynagumper using that database
             import gump.actor.mysql.dynagumper
             self.run.registerActor(gump.actor.mysql.dynagumper.Dynagumper(self.run,database))
-        
+
         # Document..
         # Use XDOCS if not overridden...
         xdocs=False
@@ -190,28 +190,28 @@ class GumpRunner(RunSpecific):
             documenter=TextDocumenter(self.run)
         else:
             xdocs=True
-            documenter=XDocDocumenter(	self.run,	\
+            documenter=XDocDocumenter(  self.run,       \
                                         self.run.getWorkspace().getBaseDirectory(), \
-                                        self.run.getWorkspace().getLogUrl())  
-        self.run.getOptions().setResolver(documenter.getResolver())                                                  
-        self.run.registerActor(documenter)    
-        
+                                        self.run.getWorkspace().getLogUrl())
+        self.run.getOptions().setResolver(documenter.getResolver())
+        self.run.registerActor(documenter)
+
         # Syndicate once documented
         if self.run.getOptions().isSyndicate():
-            self.run.registerActor(Syndicator(self.run))   
-            
+            self.run.registerActor(Syndicator(self.run))
+
         # Describe [once documented]
         if self.run.getOptions().isDescribe():
             try:
                 import gump.actor.rdf.describer
-                self.run.registerActor(gump.actor.rdf.describer.RDFDescriber(self.run))   
+                self.run.registerActor(gump.actor.rdf.describer.RDFDescriber(self.run))
             except Exception, details:
                 self.log.warning('Unable to register RDF Describer :  %s ' % details,
                             exc_info=1)
-            
+
         # Publish artifacts
         if self.run.getOptions().isPublish():
-            self.run.registerActor(RepositoryPublisher(self.run))   
+            self.run.registerActor(RepositoryPublisher(self.run))
 
         # Handle mvn repository proxy
         if not self.run.getEnvironment().noMvnRepoProxy:
@@ -219,32 +219,32 @@ class GumpRunner(RunSpecific):
 
         # Clear local mvn repository
         self.run.registerActor(LocalMvnRepositoryCleaner(self.run))
-                    
+
         # Synchonize
         if xdocs:
             self.run.registerActor(Synchronizer(self.run,documenter))
-        
+
         # Notify last
         if self.run.getOptions().isNotify() and self.run.getWorkspace().isNotify():
-            self.run.registerActor(Notifier(self.run))    
+            self.run.registerActor(Notifier(self.run))
         else:
             self.log.info('Not doing notifications [%s,%s]' \
                 % (self.run.getOptions().isNotify(), \
                     self.run.getWorkspace().isNotify() ) )
-        
-        # See what we have...            
+
+        # See what we have...
         self.run.logActors()
-        
-    def finalize(self):            
+
+    def finalize(self):
         # About to shutdown...
         self.run._dispatchEvent(FinalizeRunEvent(self.run))
-        
+
     def getUpdater(self):
         return self.updater
-        
+
     def getBuilder(self):
         return self.builder
-   
+
     def perform(self):
         """
         Does the actual gump work by delegating to the performRun(run) method of a subclass.
@@ -252,13 +252,13 @@ class GumpRunner(RunSpecific):
         if not hasattr(self,'performRun'):
             raise RuntimeError, \
                     'Class [' + `self.__class__` + '] needs a performRun(self,run)'
-        
+
         if not callable(self.performRun):
             raise RuntimeError, \
                     'Class [' + `self.__class__` + '] needs a callable performRun(self,run)'
-        
+
         self.log.debug('Perform run using [' + `self` + ']')
-        
+
         return self.performRun()
 
 def getRunner(run):