gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r954164 - /gump/trunk/python/gump/core/build/nant.py
Date Sun, 13 Jun 2010 04:28:03 GMT
Author: bodewig
Date: Sun Jun 13 04:28:03 2010
New Revision: 954164

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

Modified:
    gump/trunk/python/gump/core/build/nant.py

Modified: gump/trunk/python/gump/core/build/nant.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/build/nant.py?rev=954164&r1=954163&r2=954164&view=diff
==============================================================================
--- gump/trunk/python/gump/core/build/nant.py (original)
+++ gump/trunk/python/gump/core/build/nant.py Sun Jun 13 04:28:03 2010
@@ -1,6 +1,5 @@
 #!/usr/bin/python
 
-
 # Licensed to the Apache Software Foundation (ASF) under one or more
 # contributor license agreements.  See the NOTICE file distributed with
 # this work for additional information regarding copyright ownership.
@@ -11,180 +10,173 @@
 #     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.
 
-__revision__  = "$Rev: 36667 $"
-__date__      = "$Date: 2004-08-20 08:55:45 -0600 (Fri, 20 Aug 2004) $"
-__copyright__ = "Copyright (c) 1999-2004 Apache Software Foundation"
-__license__   = "http://www.apache.org/licenses/LICENSE-2.0"
+from gump import log
+from gump.core.run.gumprun import RunSpecific
+
+from gump.util.process.command import CMD_STATE_SUCCESS, CMD_STATE_TIMED_OUT, \
+    Cmd, Parameters
+from gump.util.process.launcher import execute
+from gump.util.work import CommandWorkItem, WORK_TYPE_BUILD
 
+from gump.core.model.state import REASON_BUILD_FAILED, REASON_BUILD_TIMEDOUT, \
+    STATE_FAILED, STATE_SUCCESS
 
-"""
-	A NAnt builder (uses nant to build projects)
-"""
+class NAntBuilder(RunSpecific):
+    """
+        A NAnt builder (uses nant to build projects)
+    """
 
-import os.path
-import sys
 
-from gump import log
-from gump.core.run.gumprun import *
-from gump.core.config import dir, default, basicConfig
+    def __init__(self, run):
+        """
+                The NAnt Builder is a .NET Builder
+        """ 
+        RunSpecific.__init__(self, run)
+
+    def buildProject(self, project, language, _stats):
+        """
+                Build a project using NAnt, based off the <nant metadata.
+
+                Note: switch on -verbose|-debug based of the stats for this
+                project, i.e. how long in a state of failure.
+        """
 
-from gump.util.note import Annotatable
-from gump.util.work import *
+        workspace = self.run.getWorkspace()
 
-from gump.util.tools import *
+        log.info('Run NAnt on Project: #[' + `project.getPosition()` + \
+                     '] : ' + project.getName())
 
-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 *
-
-class NAntBuilder(gump.core.run.gumprun.RunSpecific):
-    
-    def __init__(self,run):
-        """
-        	The NAnt Builder is a Java Builder
-    	""" 
-        gump.core.run.gumprun.RunSpecific.__init__(self,run)
-
-    def buildProject(self,project,language,stats):
-        """
-        	Build a project using NAnt, based off the <nant metadata.
-        	
-        	Note: switch on -verbose|-debug based of the stats for this
-        	project, i.e. how long in a state of failure.
-        """
-        
-        workspace=self.run.getWorkspace()
-                 
-        log.info('Run NAnt on Project: #[' + `project.getPosition()` + '] : ' + project.getName())
-    
         # Get the appropriate build command...
-        cmd=self.getNAntCommand(project, language)
+        cmd = self.getNAntCommand(project, language)
 
         if cmd:
             # Execute the command ....
-            cmdResult=execute(cmd,workspace.tmpdir)
-    
+            cmdResult = execute(cmd, workspace.tmpdir)
+
             # Update context with the fact that this work was done
-            work=CommandWorkItem(WORK_TYPE_BUILD,cmd,cmdResult)
+            work = CommandWorkItem(WORK_TYPE_BUILD, cmd, cmdResult)
             project.performedWork(work)
             project.setBuilt(True)
-                    
-            # Update context state based of the result  
-            if not cmdResult.state==CMD_STATE_SUCCESS:
-                reason=REASON_BUILD_FAILED
-                if cmdResult.state==CMD_STATE_TIMED_OUT:
-                    reason=REASON_BUILD_TIMEDOUT
-                project.changeState(STATE_FAILED,reason)                        
-            else:                         
+
+            # Update context state based of the result
+            if not cmdResult.state == CMD_STATE_SUCCESS:
+                reason = REASON_BUILD_FAILED
+                if cmdResult.state == CMD_STATE_TIMED_OUT:
+                    reason = REASON_BUILD_TIMEDOUT
+                project.changeState(STATE_FAILED, reason)
+            else:
                 # For now, things are going good...
                 project.changeState(STATE_SUCCESS)
-    
-    def getNAntCommand(self,project,languageHelper):
+
+    def getNAntCommand(self, project, languageHelper):
         """
-        	Build an ANT command for this project, based on the <nant metadata
-   			select targets and build files as appropriate.     	
+        Build an ANT command for this project, based on the <nant metadata
+        select targets and build files as appropriate.
         """
-        
+
         # The original model information...
-        nant=project.nant
+        nant = project.nant
         # The nant target (or none == nant default target)
-        target= nant.getTarget()
-    
+        target = nant.getTarget()
+
         # The nant build file (or none == build.xml)
         buildfile = nant.getBuildFile()
-    
+
         # Optional 'verbose' or 'debug'
-        verbose=nant.isVerbose()
-        debug=nant.isDebug()
-    
+        verbose = nant.isVerbose()
+        debug = nant.isDebug()
+
         # Where to run this:
         basedir = nant.getBaseDirectory() or project.getBaseDirectory()
-    
+
         # Build a classpath (based upon dependencies)
-        #(classpath,bootclasspath)=language.getClasspaths(project)
-    
+        #(classpath, bootclasspath) = language.getClasspaths(project)
+
         # Get properties
-        properties=self.getNAntProperties(project)
-   
+        properties = self.getNAntProperties(project)
+
         # Get system properties
-        sysproperties=self.getNAntSysProperties(project)
-        
+        sysproperties = self.getNAntSysProperties(project)
+
         # Library Path
-        libpath=languageHelper.getAssemblyPath(project)
-        
+        libpath = languageHelper.getAssemblyPath(project)
+
         # Run java on apache NAnt...
-        cmd=Cmd('NAnt.exe','build_'+project.getModule().getName()+'_'+project.getName(),
-            basedir,{'DEVPATH':libpath})
-        
+        cmd = Cmd('NAnt.exe', 'build_' + project.getModule().getName() + '_' + \
+                    project.getName(), 
+                basedir, {'DEVPATH' : libpath})
+
         # Launch with specified framework (e.g. mono-1.0.1) if
         # required.
-        workspace=self.run.getWorkspace()
+        workspace = self.run.getWorkspace()
         if workspace.hasDotNetInformation():
-            dotnetInfo=workspace.getDotNetInformation()
-            if dotnetInfo.hasFramework():                
-                cmd.addParameter('-t:',dotnetInfo.getFramework(),'')
-   
+            dotnetInfo = workspace.getDotNetInformation()
+            if dotnetInfo.hasFramework():
+                cmd.addParameter('-t:', dotnetInfo.getFramework(), '')
+
         # These are workspace + project system properties
         cmd.addNamedParameters(sysproperties)
-        
+
         # Get/set JVM properties
-        #jvmargs=language.getJVMArgs(project)
+        #jvmargs = language.getJVMArgs(project)
         #if jvmargs:
         #    cmd.addParameters(jvmargs)
-       
+
         # Allow ant-level debugging...
         if project.getWorkspace().isDebug() or project.isDebug() or debug: 
-            cmd.addParameter('-debug')  
-        if project.getWorkspace().isVerbose()  or project.isVerbose() or verbose: 
-            cmd.addParameter('-verbose')  
-    
+            cmd.addParameter('-debug')
+        if project.getWorkspace().isVerbose() or project.isVerbose() \
+                or verbose: 
+            cmd.addParameter('-verbose')
+
         # Some builds might wish for this information
         # :TODO: Grant greater access to Gump variables from
         # within.
-        mergeFile=project.getWorkspace().getMergeFile()
+        mergeFile = project.getWorkspace().getMergeFile()
         if mergeFile:
-            cmd.addPrefixedParameter('-D:','gump.merge',str(mergeFile),'=')        
-    
+            cmd.addPrefixedParameter('-D:', 'gump.merge', str(mergeFile), ' = ')
         # These are from the project and/or workspace
         # These are 'normal' properties.
         cmd.addNamedParameters(properties)
-    
+
         # Pass the buildfile
-        if buildfile: cmd.addParameter('-buildfile',buildfile, ':')
-    
+        if buildfile:
+            cmd.addParameter('-buildfile', buildfile, ':')
+
         # End with the target (or targets)...
         if target: 
-            for targetParam in target.split(','):
+            for targetParam in target.split(', '):
                 cmd.addParameter(targetParam)
-    
+
         return cmd
-  
-    def getNAntProperties(self,project):
+
+    def getNAntProperties(self, project):
         """ Get properties for a project """
-        properties=Parameters()
-        for property in project.getWorkspace().getProperties()+project.getNAnt().getProperties():
-            properties.addPrefixedNamedParameter('-D:',property.name,property.value,'=')
+        properties = Parameters()
+        for prop in project.getWorkspace().getProperties() + \
+                project.getNAnt().getProperties():
+            properties.addPrefixedNamedParameter('-D:', prop.name, 
+                                                 prop.value, ' = ')
         return properties
 
-    def getNAntSysProperties(self,project):
+    def getNAntSysProperties(self, project):
         """ Get sysproperties for a project """
-        properties=Parameters()
-        for property in project.getWorkspace().getSysProperties()+project.getNAnt().getSysProperties():
-            properties.addPrefixedNamedParameter('-D:',property.name,property.value,'=')
+        properties = Parameters()
+        for prop in project.getWorkspace().getSysProperties() + \
+                project.getNAnt().getSysProperties():
+            properties.addPrefixedNamedParameter('-D:', prop.name, 
+                                                 prop.value, ' = ')
         return properties
-                
-    def preview(self,project,language,stats):        
+
+    def preview(self, project, language, _stats):
         """
-        	Preview what an NAnt build would look like.
+                Preview what an NAnt build would look like.
         """
-        command=self.getNAntCommand(project,language) 
-        command.dump()
+        cmd = self.getNAntCommand(project, language) 
+        cmd.dump()
  



Mime
View raw message