gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r110051 - in gump/trunk/python/gump: actor/mysql actor/stats/mysql core core/build core/model core/run core/runner util
Date Mon, 06 Dec 2004 23:34:28 GMT
Author: ajack
Date: Mon Dec  6 15:34:27 2004
New Revision: 110051

URL: http://svn.apache.org/viewcvs?view=rev&rev=110051
Log:
Starting work on Stefano's/Leo's Historical DB.
For now run with -H and --official to see anything.
Also we (currently) need both old and new DB schema in on DB.

	gump -H --verbose --official all
Modified:
   gump/trunk/python/gump/actor/mysql/databaser.py
   gump/trunk/python/gump/actor/stats/mysql/statsdb.py
   gump/trunk/python/gump/core/build/builder.py
   gump/trunk/python/gump/core/commandLine.py
   gump/trunk/python/gump/core/model/propagation.py
   gump/trunk/python/gump/core/model/state.py
   gump/trunk/python/gump/core/run/options.py
   gump/trunk/python/gump/core/runner/runner.py
   gump/trunk/python/gump/util/mysql.py

Modified: gump/trunk/python/gump/actor/mysql/databaser.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/actor/mysql/databaser.py?view=diff&rev=110051&p1=gump/trunk/python/gump/actor/mysql/databaser.py&r1=110050&p2=gump/trunk/python/gump/actor/mysql/databaser.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/actor/mysql/databaser.py	(original)
+++ gump/trunk/python/gump/actor/mysql/databaser.py	Mon Dec  6 15:34:27 2004
@@ -69,7 +69,7 @@
                 settings['start']="'" + module.getStart().getTimestamp().strftime('%Y-%m-%d
%H:%M:%S') + "'"
                 settings['end']="'" + module.getEnd().getTimestamp().strftime('%Y-%m-%d %H:%M:%S')
+ "'"
             
-            helper.insert('module_run',settings)
+            helper.insert('gump_module_run',settings)
             
         finally:
             if conn: conn.close()
@@ -99,7 +99,7 @@
                 settings['start']="'" + project.getStart().getTimestamp().strftime('%Y-%m-%d
%H:%M:%S') + "'"
                 settings['end']="'" + project.getEnd().getTimestamp().strftime('%Y-%m-%d
%H:%M:%S') + "'"
             
-            helper.insert('project_run',settings)
+            helper.insert('gump_project_run',settings)
             
         finally:
             if conn: conn.close()

Modified: gump/trunk/python/gump/actor/stats/mysql/statsdb.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/actor/stats/mysql/statsdb.py?view=diff&rev=110051&p1=gump/trunk/python/gump/actor/stats/mysql/statsdb.py&r1=110050&p2=gump/trunk/python/gump/actor/stats/mysql/statsdb.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/actor/stats/mysql/statsdb.py	(original)
+++ gump/trunk/python/gump/actor/stats/mysql/statsdb.py	Mon Dec  6 15:34:27 2004
@@ -83,52 +83,52 @@
     def getWorkspaceStats(self,workspaceName):
         stats=WorkspaceStatistics(workspaceName)
         try:
-            self._getStats('workspace_stats','workspace_name',workspaceName,stats)
+            self._getStats('gump_workspace_stats','workspace_name',workspaceName,stats)
         except IndexError:
             pass
         return stats
         
     def putWorkspaceStats(self,stats):
-        self._putStats('workspace_stats','workspace_name',stats)
+        self._putStats('gump_workspace_stats','workspace_name',stats)
 
     def delWorkspaceStats(self,stats):
-        self._delStats('workspace_stats','workspace_name',stats)          
+        self._delStats('gump_workspace_stats','workspace_name',stats)          
         
     # Project    
     def getProjectStats(self,projectName):
         stats=ProjectStatistics(projectName)         
         try:
-            self._getStats('project_stats','project_name',projectName,stats)         
+            self._getStats('gump_project_stats','project_name',projectName,stats)       
 
         except IndexError:
             pass
         return stats
                 
     def putProjectStats(self,stats): 
-        self._putStats('project_stats','project_name',stats)
+        self._putStats('gump_project_stats','project_name',stats)
         
     def delProjectStats(self,stats): 
-        self._delStats('project_stats','project_name',stats)
+        self._delStats('gump_project_stats','project_name',stats)
 
     # Repository 
     def getRepositoryStats(self,repositoryName):
         stats=RepositoryStatistics(repositoryName)     
         try:   
-            self._getStats('repository_stats','repository_name',repositoryName,stats)
+            self._getStats('gump_repository_stats','repository_name',repositoryName,stats)
         except IndexError:
             pass    
         return stats
                 
     def putRepositoryStats(self,stats):
-        self._putStats('repository_stats','repository_name',stats)  
+        self._putStats('gump_repository_stats','repository_name',stats)  
 
     def delRepositoryStats(self,stats):
-        self._delStats('repository_stats','repository_name',stats)          
+        self._delStats('gump_repository_stats','repository_name',stats)          
 
     # Module    
     def getModuleStats(self,moduleName):
         stats=ModuleStatistics(moduleName)        
         try:
-            settings = self._getStats('module_stats','module_name',moduleName,stats)
+            settings = self._getStats('gump_module_stats','module_name',moduleName,stats)
             
             # Extract that extra
             if settings.has_key('last_modified') and settings['last_modified']:
@@ -148,10 +148,10 @@
         extras=None
         if stats.lastModified:
             extras={'last_modified':"'" + stats.lastModified.strftime('%Y-%m-%d %H:%M:%S')
+ "'"}        
-        self._putStats('module_stats','module_name',stats,extras)
+        self._putStats('gump_module_stats','module_name',stats,extras)
 
     def delModuleStats(self,stats):
-        self._delStats('module_stats','module_name',stats)     
+        self._delStats('gump_module_stats','module_name',stats)     
         
         
     # Helpers...

Modified: gump/trunk/python/gump/core/build/builder.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/core/build/builder.py?view=diff&rev=110051&p1=gump/trunk/python/gump/core/build/builder.py&r1=110050&p2=gump/trunk/python/gump/core/build/builder.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/core/build/builder.py	(original)
+++ gump/trunk/python/gump/core/build/builder.py	Mon Dec  6 15:34:27 2004
@@ -118,8 +118,8 @@
             if project.okToPerformWork():        
                 log.debug('Performing Build Upon: [' + `project.getPosition()` + '] ' + project.getName())
 
-                if project.isPrereqFailed():
-                    project.addWarning('Building despite certain prerequisite failures [repository
build].')
+                #if project.isPrereqFailed():
+                #    project.addWarning('Building despite certain prerequisite failures [repository
build].')
                     
                 # Turn on --verbose or --debug if failing ...
                 #if stats:

Modified: gump/trunk/python/gump/core/commandLine.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/core/commandLine.py?view=diff&rev=110051&p1=gump/trunk/python/gump/core/commandLine.py&r1=110050&p2=gump/trunk/python/gump/core/commandLine.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/core/commandLine.py	(original)
+++ gump/trunk/python/gump/core/commandLine.py	Mon Dec  6 15:34:27 2004
@@ -113,6 +113,10 @@
                 #
                 self.options.setDated(True)                    
                 log.info('Dated Operation (add date to log dir)')
+            elif arg in ['-H','--historical']:
+                removers.append(arg)    
+                self.options.setHistorical(True)                    
+                log.info('Historical Database Operation')
             elif arg in ['-O','--official']:
                 removers.append(arg)    
                 self.options.setOfficial(True)                    

Modified: gump/trunk/python/gump/core/model/propagation.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/core/model/propagation.py?view=diff&rev=110051&p1=gump/trunk/python/gump/core/model/propagation.py&r1=110050&p2=gump/trunk/python/gump/core/model/propagation.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/core/model/propagation.py	(original)
+++ gump/trunk/python/gump/core/model/propagation.py	Mon Dec  6 15:34:27 2004
@@ -65,7 +65,6 @@
                 # Send on the changes...
                 self.propagateErrorStateChange(state,reason,cause,message)
     
-
     def propagateErrorStateChange(self,state,reason,cause,message):
                
         # .. then push this error down

Modified: gump/trunk/python/gump/core/model/state.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/core/model/state.py?view=diff&rev=110051&p1=gump/trunk/python/gump/core/model/state.py&r1=110050&p2=gump/trunk/python/gump/core/model/state.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/core/model/state.py	(original)
+++ gump/trunk/python/gump/core/model/state.py	Mon Dec  6 15:34:27 2004
@@ -2,7 +2,6 @@
 
 # Copyright 2003-2004 The Apache Software Foundation
 #
-# Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 # 

Modified: gump/trunk/python/gump/core/run/options.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/core/run/options.py?view=diff&rev=110051&p1=gump/trunk/python/gump/core/run/options.py&r1=110050&p2=gump/trunk/python/gump/core/run/options.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/core/run/options.py	(original)
+++ gump/trunk/python/gump/core/run/options.py	Mon Dec  6 15:34:27 2004
@@ -65,6 +65,7 @@
 FEATURE_DESCRIBE=0x20
 FEATURE_PUBLISH=0x40
 FEATURE_DOCUMENT=0x80
+FEATURE_HISTORICAL=0x80
 
 FEATURE_DEFAULT=FEATURE_STATISTICS|FEATURE_SYNDICATE|FEATURE_DESCRIBE|FEATURE_DOCUMENT|FEATURE_NOTIFY
             
@@ -93,6 +94,7 @@
         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        
@@ -107,7 +109,13 @@
         return self.dated
         
     def setDated(self,dated):
-        self.dated=dated
+        self.dated=dated        
+        
+    def isHistorical(self):
+        return self.historical
+        
+    def setHistorical(self,historical):
+        self.historical=historical
         
     def isOfficial(self):
         """
@@ -272,6 +280,9 @@
 
     def isStatistics(self):
         return self._testFeatureIsSet(FEATURE_STATISTICS)
+
+    def isHistorical(self):
+        return self._testFeatureIsSet(FEATURE_HISTORICAL)
 
     def isDocument(self):
         """

Modified: gump/trunk/python/gump/core/runner/runner.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/core/runner/runner.py?view=diff&rev=110051&p1=gump/trunk/python/gump/core/runner/runner.py&r1=110050&p2=gump/trunk/python/gump/core/runner/runner.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/core/runner/runner.py	(original)
+++ gump/trunk/python/gump/core/runner/runner.py	Mon Dec  6 15:34:27 2004
@@ -135,12 +135,24 @@
 
         # Add Database storer
         if self.run.getOptions().isOfficial() and \
-            self.run.getWorkspace().hasDatabaseInformation():
+            self.run.getWorkspace().hasDatabaseInformation() and \
+            not self.run.getOptions().isHistorical():    
             try:
                 import gump.actor.mysql.databaser
                 self.run.registerActor(gump.actor.mysql.databaser.Databaser(self.run))
             except Exception, details:
                 log.warning('Unable to register Database Actor :  %s ' % details,
+                            exc_info=1)
+        
+        # Add Historical Database storer
+        if self.run.getOptions().isOfficial() and \
+            self.run.getWorkspace().hasDatabaseInformation() and \
+            self.run.getOptions().isHistorical():       
+            try:
+                import gump.actor.history.historical
+                self.run.registerActor(gump.actor.history.historical.Historical(self.run))
+            except Exception, details:
+                log.warning('Unable to register Historical Database Actor :  %s ' % details,
                             exc_info=1)
         
         # Document..

Modified: gump/trunk/python/gump/util/mysql.py
Url: http://svn.apache.org/viewcvs/gump/trunk/python/gump/util/mysql.py?view=diff&rev=110051&p1=gump/trunk/python/gump/util/mysql.py&r1=110050&p2=gump/trunk/python/gump/util/mysql.py&r2=110051
==============================================================================
--- gump/trunk/python/gump/util/mysql.py	(original)
+++ gump/trunk/python/gump/util/mysql.py	Mon Dec  6 15:34:27 2004
@@ -19,6 +19,7 @@
     
 """
 
+import types
 import MySQLdb
 import MySQLdb.cursors
 
@@ -37,12 +38,27 @@
         if self.conn:
             self.conn.close()
             self.conn=None
+            
+    def value(self,value):
+        """
+        Escape and Quote a Value
+        """
+        escaped_encoded = ''
+        
+        if isinstance(value,types.StringTypes):
+            escaped_encoded = "'" 
+            escaped_encoded += MySQLdb.escape_string(value).replace("\\","\\\\").replace("'","\\'")
+            escaped_encoded += "'"            
+        else:
+            escaped_encoded = value
+            
+        return escaped_encoded
  
     def generateSelect(self,table_name,column_name,entity_name):
         """
         Generate a select statement, index is a single name
         """ 
-        statement="SELECT * FROM %s.gump_%s WHERE %s='%s'" % (self.database, table_name,
column_name, entity_name) 
+        statement="SELECT * FROM %s.%s WHERE %s='%s'" % (self.database, table_name, column_name,
entity_name) 
         return statement
         
     def select(self,table_name,column_name,entity_name,columns):
@@ -75,18 +91,27 @@
 
     def set(self,table_name,column_name,entity_name,settings):
         
+        # Unfortunately affected is returning 0 even when
+        # there is a match.
+        
         # Attempt an update (and ensure we affected something)
-        updated=(self.update(table_name,column_name,entity_name,settings) > 0)
+        #updated=(self.update(table_name,column_name,entity_name,settings) > 0)
+            
+        #if not updated:
+        #   # Attempt an insert if not update occured (i.e no match)
+        #    self.insert(table_name,settings)
+        
+        # Gak -- but see above.
+        self.delete(table_name,column_name,entity_name)
+        self.insert(table_name,settings)
             
-        if not updated:
-            # Attempt an insert
-            self.insert(table_name,settings)
+        return
             
     def generateInsert(self,table_name,settings): 
         """ 
         Perform an SQL INSERT 
         """
-        statement = "INSERT INTO %s.gump_%s (" % (self.database, table_name)
+        statement = "INSERT INTO %s.%s (" % (self.database, table_name)
         keys=settings.keys()
         statement += ", ".join(keys)
         statement += ") VALUES ("
@@ -121,7 +146,7 @@
         Take a dictionary of settings (column names/types) and 
         generate an update statement. Note: The index is a single name.        
         """
-        statement = "UPDATE %s.gump_%s SET " % (self.database, table_name)
+        statement = "UPDATE %s.%s SET " % (self.database, table_name)
         keys=settings.keys()
         keys.remove(column_name)
         statement += ", ".join([key + '=' + str(settings[key]) for key in keys])
@@ -140,8 +165,8 @@
             try:
                 cursor = self.conn.cursor()
                 log.debug('SQL: ' + statement)
-                affected = cursor.execute(statement)    
-                log.debug('SQL Affected: ' + `affected`)                  
+                affected = cursor.execute(statement)  
+                log.debug('SQL Affected: ' + `affected` + ':' + `result`)
             except Exception, details:
                 if cursor: self.logWarnings(cursor)    
                 log.error('SQL Error on [%s] : %s' % (statement, details), exc_info=1)
@@ -155,7 +180,7 @@
         Perform an SQL DELETE 
         Index is single name
         """
-        statement = "DELETE FROM %s.gump_%s WHERE %s='%s'" \
+        statement = "DELETE FROM %s.%s WHERE %s='%s'" \
                         % (self.database, table_name, column_name, entity_name)
         return statement
 

Mime
View raw message