gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r760784 - /gump/trunk/python/gump/core/build/mvn.py
Date Wed, 01 Apr 2009 05:07:12 GMT
Author: bodewig
Date: Wed Apr  1 05:07:11 2009
New Revision: 760784

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

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

Modified: gump/trunk/python/gump/core/build/mvn.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/build/mvn.py?rev=760784&r1=760783&r2=760784&view=diff
==============================================================================
--- gump/trunk/python/gump/core/build/mvn.py (original)
+++ gump/trunk/python/gump/core/build/mvn.py Wed Apr  1 05:07:11 2009
@@ -16,56 +16,40 @@
 # 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"
-
-
-"""
-
-"""
-
 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.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 CommandWorkItem, \
+    REASON_BUILD_FAILED, REASON_BUILD_TIMEDOUT, REASON_PREBUILD_FAILED, \
+    STATE_FAILED, STATE_SUCCESS,  WORK_TYPE_BUILD
+from gump.core.run.gumprun import RunSpecific
+from gump.util.file import FILE_TYPE_CONFIG
+from gump.util.process.command import Cmd, CMD_STATE_SUCCESS, \
+    CMD_STATE_TIMED_OUT, Parameters
+from gump.util.process.launcher import execute
+from gump.util.tools import catFileToFileHolder, wipeDirectoryTree
 
+from time import strftime
 
 ###############################################################################
 # Classes
 ###############################################################################
 
-class Maven2Builder(gump.core.run.gumprun.RunSpecific):
-    
-    def __init__(self,run):
-        gump.core.run.gumprun.RunSpecific.__init__(self,run)
+class Maven2Builder(RunSpecific):
 
-    def buildProject(self,project,languageHelper,stats):
+    def __init__(self, run):
+        RunSpecific.__init__(self, run)
+
+    def buildProject(self, project, languageHelper, stats):
         """
         Build a Maven2 project
         """
-        
-        workspace=self.run.getWorkspace()
-                
-        log.debug('Run Maven2 on Project: #[' + `project.getPosition()` + '] ' + project.getName())
-        
+
+        workspace = self.run.getWorkspace()
+
+        log.debug('Run Maven2 on Project: #[' + `project.getPosition()` + '] '\
+                  + project.getName())
+
         self.performPreBuild(project, languageHelper, stats)
 
         if project.okToPerformWork():
@@ -73,30 +57,30 @@
             #
             # Get the appropriate build command...
             #
-            cmd=self.getMavenCommand(project,languageHelper)
+            cmd = self.getMavenCommand(project, languageHelper)
 
             if cmd:
                 # Execute the command ....
-                cmdResult=execute(cmd,workspace.tmpdir)
-    
-                # Update Context    
-                work=CommandWorkItem(WORK_TYPE_BUILD,cmd,cmdResult)
+                cmdResult = execute(cmd, workspace.tmpdir)
+
+                # Update Context
+                work = CommandWorkItem(WORK_TYPE_BUILD, cmd, cmdResult)
                 project.performedWork(work)
                 project.setBuilt(True)
-                    
-                # Update Context w/ Results  
-                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 w/ Results
+                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)
-                    
+
         if project.wasBuilt():
-            pomFile=self.locateMavenProjectFile(project) 
-            if os.path.exists(pomFile):                      
+            pomFile = self.locateMavenProjectFile(project) 
+            if os.path.exists(pomFile):
                 project.addDebug('Maven POM in: ' + pomFile) 
                 catFileToFileHolder(project, pomFile, FILE_TYPE_CONFIG)
 
@@ -105,58 +89,59 @@
 
     #
     # Build an Maven command for this project
-    #        
-    def getMavenCommand(self,project,languageHelper):
-        maven=project.mvn
-    
+    #
+    def getMavenCommand(self, project, languageHelper):
+        maven = project.mvn
+
         # The maven goal (or none == maven default goal)
-        goal=maven.getGoal()
-    
+        goal = maven.getGoal()
+
         # Optional 'verbose' or 'debug'
-        verbose=maven.isVerbose()
-        debug=maven.isDebug()
-    
+        verbose = maven.isVerbose()
+        debug = maven.isDebug()
+
         #
         # Where to run this:
         #
         basedir = maven.getBaseDirectory() or project.getBaseDirectory()
-    
+
         #
         # Build a classpath (based upon dependencies)
         #
-        (classpath,bootclasspath)=languageHelper.getClasspaths(project)
-    
+        (classpath, bootclasspath) = languageHelper.getClasspaths(project)
+
         # Run Maven...
-        cmd=Cmd('mvn','build_'+project.getModule().getName()+'_'+project.getName(),\
-            basedir,{'CLASSPATH':classpath})
-            
+        cmd = Cmd('mvn', 'build_' + project.getModule().getName() + '_' + \
+                    project.getName(), basedir, {'CLASSPATH':classpath})
+
         cmd.addParameter('--batch-mode')
 
         #
         # Allow maven-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('--debug')
+        if project.getWorkspace().isVerbose() \
+                or project.isVerbose() or verbose: 
             cmd.addParameter('--exception') 
-        
+
         props = self.getProperties(project)
         cmd.addNamedParameters(props)
 
         #
         # Suppress downloads
-        #          
+        #
 
         # As long as we don't know how to pass our local artifacts to
         # mvn there is no point in using the offline mode
         #
-        # cmd.addParameter('--offline')  
-        
+        # cmd.addParameter('--offline')
+
         #
-        #	This sets the *defaults*, a workspace could override them.
+        #       This sets the *defaults*, a workspace could override them.
         #
-        #cmd.addPrefixedParameter('-D','build.sysclasspath','only','=')
-    
+        #cmd.addPrefixedParameter('-D', 'build.sysclasspath', 'only', '=')
+
         cmd.addParameter('--settings')
         cmd.addParameter(self.locateMvnSettings(project))
 
@@ -164,67 +149,73 @@
         if goal: 
             for goalParam in goal.split(','):
                 cmd.addParameter(goalParam)
-    
+
         return cmd
-  
-    def getProperties(self,project):
+
+    def getProperties(self, project):
         """ Get properties for a project """
         properties = Parameters()
         for property in project.getMvn().getProperties():
-            properties.addPrefixedNamedParameter('-D',property.name,property.value,'=')
+            properties.addPrefixedNamedParameter('-D', property.name, \
+                                                     property.value, '=')
         return properties
 
-    def locateMavenProjectFile(self,project):
-        """Return Maven project file location"""      
+    def locateMavenProjectFile(self, project):
+        """Return Maven project file location"""
         basedir = project.mvn.getBaseDirectory() or project.getBaseDirectory()
-        return os.path.abspath(os.path.join(basedir,'pom.xml'))  
-        
+        return os.path.abspath(os.path.join(basedir, 'pom.xml'))
+
     # Do this even if not ok
     def performPreBuild(self, project, languageHelper, stats):
-                   
+
         # Maven requires a build.properties to be generated...
         if project.okToPerformWork():
             try:
-                settingsFile = self.generateMvnSettings(project,languageHelper)
-                project.addDebug('(Gump generated) Maven2 Settings in: ' + settingsFile)
-                
+                settingsFile = self.generateMvnSettings(project, languageHelper)
+                project.addDebug('(Gump generated) Maven2 Settings in: ' + \
+                                     settingsFile)
+
                 try:
                     catFileToFileHolder(project, settingsFile,
                         FILE_TYPE_CONFIG,
                         os.path.basename(settingsFile))
                 except:
-                    log.error('Display Settings [ ' + settingsFile + '] Failed', exc_info=1)
  
-               
+                    log.error('Display Settings [ ' + settingsFile + \
+                                  '] Failed', exc_info = 1)
+
             except Exception, details:
-                message='Generate Maven2 Settings Failed:' + str(details)
-                log.error(message, exc_info=1)
+                message = 'Generate Maven2 Settings Failed:' + str(details)
+                log.error(message, exc_info = 1)
                 project.addError(message)
                 project.changeState(STATE_FAILED, REASON_PREBUILD_FAILED)
 
-    def preview(self,project,languageHelper,stats):        
-        command=self.getMavenCommand(project,languageHelper) 
+    def preview(self, project, languageHelper, stats):
+        command = self.getMavenCommand(project, languageHelper) 
         command.dump()
-            
+
     def generateMvnSettings(self, project, languageHelper):
         """Set repository for a Maven2 project"""
-        
+
         settingsFile = self.locateMvnSettings(project)
         # Ensure containing directory exists, or make it.
         settingsdir = os.path.dirname(settingsFile)
         if not os.path.exists(settingsdir):
-            project.addInfo('Making directory for Maven2 settings: ['+settingsdir+']')
+            project.addInfo('Making directory for Maven2 settings: [' \
+                                + settingsdir + ']')
             os.makedirs(settingsdir)
-        
+
         if os.path.exists(settingsFile):
-            project.addWarning('Overriding Maven2 settings: ['+settingsFile+']')
-    
+            project.addWarning('Overriding Maven2 settings: [' + settingsFile \
+                                   + ']')
+
         if self.needsSeparateLocalRepository(project):
             localRepositoryDir = self.locateLocalRepo(project)
         else:
-            localRepositoryDir = self.run.getWorkspace().getLocalRepositoryDirectory()
+            localRepositoryDir = \
+                self.run.getWorkspace().getLocalRepositoryDirectory()
+
+        props = open(settingsFile, 'w')
 
-        props=open(settingsFile,'w')
-        
         props.write(("""<?xml version="1.0"?>
 <!--
 # DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT  DO NOT EDIT

@@ -239,7 +230,7 @@
 -->
 <settings>
   <localRepository>%s</localRepository>""")
-                    % (project.getName(), time.strftime('%Y-%m-%d %H:%M:%S'),
+                    % (project.getName(), strftime('%Y-%m-%d %H:%M:%S'),
                        localRepositoryDir))
         if not self.run.getEnvironment().noMvnRepoProxy:
             props.write("""
@@ -253,7 +244,7 @@
   </mirrors>""" % (self.run.getWorkspace().mvnRepoProxyPort) )
 
         props.write("</settings>")
-                   
+
         return settingsFile
 
     def locateMvnSettings(self, project):
@@ -267,8 +258,10 @@
         #
         # Where to put the local repository
         #
-        return os.path.abspath(os.path.join(self.run.getWorkspace().getBaseDirectory(),
-                                            project.getName() + ".mvnlocalrepo"))
+        return os.path.abspath(os.path.join(self.run.getWorkspace()\
+                                                .getBaseDirectory(),
+                                            project.getName() \
+                                            + ".mvnlocalrepo"))
 
     def needsSeparateLocalRepository(self, project):
         return project.mvn.needsSeparateLocalRepository()



Mime
View raw message