continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r416660 - in /maven/continuum/trunk: continuum-core-it/continuum.py continuum-core-it/continuum_cli.py continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
Date Fri, 23 Jun 2006 10:11:47 GMT
Author: evenisse
Date: Fri Jun 23 03:11:46 2006
New Revision: 416660

URL: http://svn.apache.org/viewvc?rev=416660&view=rev
Log:
[CONTINUUM-732] Add build results in xmlrpc interface and add dependencies to the python code
in continuum-core-it
Sumitted by: Andrew Williams

Modified:
    maven/continuum/trunk/continuum-core-it/continuum.py
    maven/continuum/trunk/continuum-core-it/continuum_cli.py
    maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java

Modified: maven/continuum/trunk/continuum-core-it/continuum.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core-it/continuum.py?rev=416660&r1=416659&r2=416660&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core-it/continuum.py (original)
+++ maven/continuum/trunk/continuum-core-it/continuum.py Fri Jun 23 03:11:46 2006
@@ -44,9 +44,18 @@
         return "checking out"
     elif ( state == Continuum.STATE_UPDATING ):
         return "updating"
+    elif ( state == Continuum.STATE_WARNED ):
+        return "warned"
     else:
         return "UNKNOWN STATE (" + str( state ) + ")."
 
+def decodeTrigger( trigger ):
+    if (trigger == Continuum.TRIGGER_FORCED):
+        return "forced"
+    elif (trigger == Continuum.TRIGGER_SCHEDULED):
+        return "scheduled"
+    else:
+        return "UNKNOWN TRIGGER (" + str( trigger ) + ")."
 def makeMailNotifier( address ):
     notifier = ContinuumNotifier()
 
@@ -62,6 +71,10 @@
     STATE_BUILDING = 6
     STATE_CHECKING_OUT = 7
     STATE_UPDATING = 8
+    STATE_WARNED = 9
+
+    TRIGGER_SCHEDULED = 0
+    TRIGGER_FORCED = 1
 
     def __init__( self, url ):
         self.server = xmlrpclib.Server(url, allow_none=True)
@@ -95,7 +108,7 @@
         return self.makeProject( result[ "project" ] )
 
     def getProjects( self ):
-        result = checkResult( self.server.continuum.getAllProjects() )
+        result = checkResult( self.server.continuum.getProjects() )
 
         projects = []
         for project in result[ "projects" ]:
@@ -111,12 +124,12 @@
         checkResult( self.server.continuum.buildProject( projectId, force ) )
 
     def getBuild( self, buildId ):
-        result = checkResult( self.server.continuum.getBuild( buildId ) )
+        result = checkResult( self.server.continuum.getBuildResult( buildId ) )
 
         return Build( result[ "build" ] )
 
-    def getBuildsForProject( self, projectId, start=0, end=0 ):
-        result = checkResult( self.server.continuum.getBuildsForProject( projectId, start,
end ) )
+    def getBuildsForProject( self, projectId ):
+        result = checkResult( self.server.continuum.getBuildResultsForProject( projectId
) )
 
         builds = []
         for build in result[ "builds" ]:
@@ -216,19 +229,23 @@
 class Project:
     def __init__( self, map ):
         self.map = map;
+        self.dependencies = []
         self.developers = []
         self.notifiers = []
 
         if ( map == None ):
             return
 
-#        map[ "state" ] = decodeState( int( map[ "state" ] ) )
         self.id = map[ "id" ]
         self.name = map[ "name" ]
         self.scmUrl = map[ "scmUrl" ]
         self.version = map[ "version" ]
-        self.workingDirectory = map[ "workingDirectory" ]
-#        self.state = int( map[ "state" ] )
+        self.build = map[ "buildNumber" ]
+        if ( map.has_key( "workingDirectory" ) ):
+            self.workingDirectory = map[ "workingDirectory" ]
+        else:
+            self.workingDirectory = ""
+        self.state = int( map[ "state" ] )
         self.executorId = map[ "executorId" ]
 
         if ( map.has_key( "commandLineArguments" ) ):
@@ -251,6 +268,11 @@
         else:
             self.checkOutErrorException = None
 
+        self.dependencies = list()
+        if ( map.has_key( "dependencies" ) ):
+            for f in map[ "dependencies" ]:
+                self.dependencies.append( ContinuumDependency( f ) )
+
         self.developers = list()
         if ( map.has_key( "developers" ) ):
             for f in map[ "developers" ]:
@@ -261,12 +283,12 @@
             for f in map[ "notifiers" ]:
                 self.notifiers.append( ContinuumNotifier( f ) )
 
-# "state: " + decodeState( self.state ) + os.linesep +\
     def __str__( self ):
         s = "id: " + self.id + os.linesep +\
             "name: " + self.name + os.linesep +\
             "version: " + self.version + os.linesep +\
-            "executor id: " + self.executorId + os.linesep
+            "executor id: " + self.executorId + os.linesep +\
+            "state: " + decodeState( self.state ) + os.linesep
 
         return s
 
@@ -277,7 +299,8 @@
         if ( map == None ):
             return
     
-        self.goals = map[ "goals" ]
+        self.goals = '' #map[ "goals" ]
+        self.group = map[ "groupId" ]
 
     def __str__( self ):
         return Project.__str__( self ) + os.linesep +\
@@ -290,7 +313,8 @@
         if ( map == None ):
             return
     
-        self.goals = map[ "goals" ]
+        self.goals = '' #map[ "goals" ]
+        self.group = map[ "groupId" ]
 
     def __str__( self ):
         return Project.__str__( self ) + os.linesep +\
@@ -302,9 +326,9 @@
 
         if ( map == None ):
             return
-    
-        self.executable = map[ "executable" ]
-        self.targets = map[ "targets" ]
+        print map 
+#        self.executable = map[ "executable" ]
+#        self.targets = map[ "goals" ]
 
     def __str__( self ):
         return Project.__str__( self ) + os.linesep +\
@@ -326,15 +350,23 @@
 
 class Build:
     def __init__( self, map ):
-        #map[ "state" ] = decodeState( int( map[ "state" ] ) )
-        map[ "forced" ] = bool( map[ "forced" ] )
+        print map
         map[ "totalTime" ] = int( map[ "endTime" ] )/ 1000 - int( map[ "startTime" ] ) /
1000
         map[ "startTime" ] = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime( int( map[ "startTime"
] ) / 1000 ) )
         map[ "endTime" ] = strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime( int( map[ "endTime"
] ) / 1000 ) )
 
         self.id = map[ "id" ]
+	self.buildNumber = map[ "buildNumber" ]
+        if self.buildNumber == '0':
+            self.buildNumber = ''
         self.state = int( map[ "state" ] )
-        self.forced = map[ "forced" ]
+        if ( map.has_key( "trigger" ) ):
+            self.forced = map[ "trigger" ] == Continuum.TRIGGER_FORCED
+            self.trigger = int( map[ "trigger" ] )
+        else:
+            self.forced = false
+            self.trigger = 0
+
         self.startTime = map[ "startTime" ]
         self.endTime = map[ "endTime" ]
         self.totalTime = map[ "totalTime" ]
@@ -443,9 +475,19 @@
         self.map = map
         self.path = map[ "path" ]
 
+class ContinuumDependency:
+    def __init__( self, map ):
+        self.group = map[ "groupId" ]
+        self.artifact = map[ "artifactId" ]
+        self.version = map[ "version" ]
+
+    def __str__( self ):
+        value = self.group + ":" + self.artifact + ":" + self.version
+        return value
+
 class ContinuumDeveloper:
     def __init__( self, map ):
-        self.id = map[ "id" ]
+        self.id = map[ "continuumId" ]
         self.name = map[ "name" ]
         self.email = map[ "email" ]
 

Modified: maven/continuum/trunk/continuum-core-it/continuum_cli.py
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core-it/continuum_cli.py?rev=416660&r1=416659&r2=416660&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core-it/continuum_cli.py (original)
+++ maven/continuum/trunk/continuum-core-it/continuum_cli.py Fri Jun 23 03:11:46 2006
@@ -64,14 +64,14 @@
         """Shows Continuum project.
         Use this command to show the details of a Continuum project."""
 
-        project = c.getProject( args[0] )
+        project = c.getProject( int( args[0])  )
 
         print "Project details:"
         print "Id: " + project.id
         print "Name:               " + project.name
         print "Version:            " + project.version
         print "Working directory:  " + project.workingDirectory
-#        print "State:              " + continuum.decodeState( project.state )
+        print "State:              " + continuum.decodeState( project.state )
         print "Executor type:      " + project.executorId
         print "SCM URL:            " + project.scmUrl
 
@@ -86,7 +86,7 @@
             print ""
             print project.checkOutScmResult
 
-            builds = c.getBuildsForProject( project.id, 0, 0 )
+            builds = c.getBuildsForProject( int( project.id ) )
             print ""
             print "Project Builds:"
             print "|  Id  |  State |           Start time            |             End time
           | Build time |"

Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java?rev=416660&r1=416659&r2=416660&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
(original)
+++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
Fri Jun 23 03:11:46 2006
@@ -22,6 +22,7 @@
 import org.apache.maven.continuum.execution.maven.m2.MavenTwoBuildExecutor;
 import org.apache.maven.continuum.execution.shell.ShellBuildExecutor;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.util.StringUtils;
@@ -110,6 +111,41 @@
         }
     }
 
+    public Hashtable getBuildResult( int buildId )
+    {
+        try
+        {
+            BuildResult build = continuum.getBuildResult( buildId );
+
+            return makeHashtable( "build", convertContinuumBuild( build, false ) );
+        }
+        catch ( Throwable e )
+        {
+            return handleException( "ContinuumXmlRpc.getBuildResult()", "Build id: '" + buildId
+ "'.", e );
+        }
+    }
+
+    public Hashtable getBuildResultsForProject( int projectId )
+    {
+        try
+        {
+            Collection buildResults = continuum.getBuildResultsForProject( projectId );
+
+            Vector results = new Vector( buildResults.size() );
+
+            for ( Iterator it = buildResults.iterator(); it.hasNext(); )
+            {
+                results.add( convertContinuumBuild( it.next(), true ) );
+            }
+
+            return makeHashtable( "builds", results );
+        }
+        catch ( Throwable e )
+        {
+            return handleException( "ContinuumXmlRpc.getBuildResultsForProject()", "Project
id: '" + projectId + "'.", e );
+        }
+    }
+
     // ----------------------------------------------------------------------
     // Build handling
     // ----------------------------------------------------------------------
@@ -402,12 +438,19 @@
         return hashtable;
     }
 
-    private Hashtable convertContinuumBuild( Object object )
+    private Hashtable convertContinuumBuild( Object object, boolean summary )
         throws IllegalAccessException, InvocationTargetException
     {
         Set excludedProperties = new HashSet();
 
         excludedProperties.add( "project" );
+
+        if ( summary )
+        {
+            excludedProperties.add( "scmResult" );
+            excludedProperties.add( "trigger" );
+            excludedProperties.add( "error" );
+        }
 
         return xmlRpcHelper.objectToHashtable( object, excludedProperties );
     }



Mime
View raw message