gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r990012 - in /gump/trunk/python/gump: actor/mysql/databaser.py util/mysql.py
Date Fri, 27 Aug 2010 04:10:14 GMT
Author: bodewig
Date: Fri Aug 27 04:10:14 2010
New Revision: 990012

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

Modified:
    gump/trunk/python/gump/actor/mysql/databaser.py
    gump/trunk/python/gump/util/mysql.py

Modified: gump/trunk/python/gump/actor/mysql/databaser.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/actor/mysql/databaser.py?rev=990012&r1=990011&r2=990012&view=diff
==============================================================================
--- gump/trunk/python/gump/actor/mysql/databaser.py (original)
+++ gump/trunk/python/gump/actor/mysql/databaser.py Fri Aug 27 04:10:14 2010
@@ -10,7 +10,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.
@@ -19,104 +19,104 @@
     Stash in Database
 """
 
-import time
-import os
-import sys
-
 import MySQLdb
 import MySQLdb.cursors
 
-from gump import log
-from gump.core.run.gumprun import *
 import gump.core.run.actor
 
 class Databaser(gump.core.run.actor.AbstractRunActor):
-    
-    def __init__(self,run):              
-        gump.core.run.actor.AbstractRunActor.__init__(self,run)    
-        self.dbInfo=self.workspace.getDatabaseInformation()
-        
-    def processOtherEvent(self,event):   
+
+    def __init__(self, run):
+        gump.core.run.actor.AbstractRunActor.__init__(self, run)
+        self.dbInfo = self.workspace.getDatabaseInformation()
+
+    def processOtherEvent(self, event):
         pass
-                      
+
     def processWorkspace(self):
         """
         Add information about the workspace to the database 
         """
         pass
-    
-    def processModule(self,module):    
+
+    def processModule(self, module):
         """
         Add information about the module to the database
         """
-        conn=None
-        helper=None
+        conn = None
+        helper = None
         try:
-            conn=self.getConnected()
-            helper=gump.util.mysql.DbHelper(conn,self.dbInfo.getDatabase())
-            
+            conn = self.getConnected()
+            helper = gump.util.mysql.DbHelper(conn, self.dbInfo.getDatabase())
+
             # Prepare the data
             settings = {}
-            
-            settings['run_id'] = "'" + self.run.getRunHexGuid() + "'"  
-            settings['module_name']="'" + module.getName() + "'"
-            settings['state']=module.getState()
-            settings['reason']=module.getReason()
-            
+
+            settings['run_id'] = "'" + self.run.getRunHexGuid() + "'"
+            settings['module_name'] = "'" + module.getName() + "'"
+            settings['state'] = module.getState()
+            settings['reason'] = module.getReason()
+
             if module.hasCause():
-                settings['cause']="'" + module.getCause().getName() + "'"
-                
+                settings['cause'] = "'" + module.getCause().getName() + "'"
+
             if module.hasTimes():
-                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('gump_module_run',settings)
-            
+                settings['start'] = "'" + _format(module.getStart())  + "'"
+                settings['end'] = "'" + _format(module.getEnd()) + "'"
+
+            helper.insert('gump_module_run', settings)
+
         finally:
-            if conn: conn.close()
-    
-    def processProject(self,project):    
+            if conn:
+                conn.close()
+
+    def processProject(self, project):
         """
         Add information about the project to the database 
         """
-        conn=None
-        helper=None
+        conn = None
+        helper = None
         try:
-            conn=self.getConnected()
-            helper=gump.util.mysql.DbHelper(conn,self.dbInfo.getDatabase())
-            
+            conn = self.getConnected()
+            helper = gump.util.mysql.DbHelper(conn, self.dbInfo.getDatabase())
+
             # Prepare the data
             settings = {}
-            
+
             settings['run_id'] = "'" + self.run.getRunHexGuid() + "'"
-            settings['project_name']="'" + project.getName() + "'"
-            settings['state']=project.getState()
-            settings['reason']=project.getReason()
-            
+            settings['project_name'] = "'" + project.getName() + "'"
+            settings['state'] = project.getState()
+            settings['reason'] = project.getReason()
+
             if project.hasCause():
-                settings['cause']="'" + project.getCause().getName() + "'"
-                
+                settings['cause'] = "'" + project.getCause().getName() + "'"
+
             if project.hasTimes():
-                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('gump_project_run',settings)
-            
+                settings['start'] = "'" + _format(project.getStart()) + "'"
+                settings['end'] = "'" + _format(project.getEnd()) + "'"
+
+            helper.insert('gump_project_run', settings)
+
         finally:
-            if conn: conn.close()
-        
-        
+            if conn:
+                conn.close()
+
+
     def getConnected(self):
         """
         Get a database connection.
         """
-                
+
         return MySQLdb.Connect(
-                    host=self.dbInfo.getHost(), 
-                    user=self.dbInfo.getUser(),
-                    passwd=self.dbInfo.getPasswd(), 
-                    db=self.dbInfo.getDatabase(),
-                    compress=1,
-                    cursorclass=MySQLdb.cursors.DictCursor)
-        
-           
+                    host = self.dbInfo.getHost(), 
+                    user = self.dbInfo.getUser(), 
+                    passwd = self.dbInfo.getPasswd(), 
+                    db = self.dbInfo.getDatabase(), 
+                    compress = 1, 
+                    cursorclass = MySQLdb.cursors.DictCursor)
+
+def _format(timestamp):
+    """
+    Formats a timestamp
+    """
+    return timestamp.getTimestamp().strftime('%Y-%m-%d %H:%M:%S')

Modified: gump/trunk/python/gump/util/mysql.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/util/mysql.py?rev=990012&r1=990011&r2=990012&view=diff
==============================================================================
--- gump/trunk/python/gump/util/mysql.py (original)
+++ gump/trunk/python/gump/util/mysql.py Fri Aug 27 04:10:14 2010
@@ -250,7 +250,7 @@ class DbHelper:
                 cursor = self.conn.cursor()
                 log.debug('SQL: ' + statement)
                 affected = cursor.execute(statement)
-                log.debug('SQL Affected: ' + `affected` + ':' + `result`)
+                log.debug('SQL Affected: ' + `affected`)
             except Exception, details:
                 if cursor:
                     self.logWarnings(cursor)



Mime
View raw message