From ea3cf9e00e4e24644c1a50b3a265e09d4aec3908 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Mon, 2 Sep 2013 18:24:22 -0400 Subject: [PATCH] minor changes to previous commit --- src/bitmessagemain.py | 15 +++++++-------- src/bitmessageqt/__init__.py | 8 ++++---- src/helper_sql.py | 2 ++ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 47ee5865..0da1fca5 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -727,16 +727,15 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): # This is not a particularly commonly used API function. Before we # use it we'll need to fill out a field in our inventory database # which is blank by default (first20bytesofencryptedmessage). - parameters = '' queryreturn = sqlQuery( '''SELECT hash, payload FROM inventory WHERE first20bytesofencryptedmessage = '' and objecttype = 'msg' ; ''') - - for row in queryreturn: - hash, payload = row - readPosition = 16 # Nonce length + time length - readPosition += decodeVarint(payload[readPosition:readPosition+10])[1] # Stream Number length - t = (payload[readPosition:readPosition+20],hash) - sqlExecute('''UPDATE inventory SET first20bytesofencryptedmessage=? WHERE hash=?; ''', t) + with SqlBulkExecute() as sql: + for row in queryreturn: + hash, payload = row + readPosition = 16 # Nonce length + time length + readPosition += decodeVarint(payload[readPosition:readPosition+10])[1] # Stream Number length + t = (payload[readPosition:readPosition+20],hash) + sql.execute('''UPDATE inventory SET first20bytesofencryptedmessage=? WHERE hash=?; ''', t) queryreturn = sqlQuery('''SELECT payload FROM inventory WHERE first20bytesofencryptedmessage = ?''', requestedHash) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index 101750d7..a60053ea 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -558,7 +558,7 @@ class MyForm(QtGui.QMainWindow): else: where = "toaddress || fromaddress || subject || message" - sql = ''' + sqlStatement = ''' SELECT toaddress, fromaddress, subject, message, status, ackdata, lastactiontime FROM sent WHERE folder="sent" AND %s LIKE ? ORDER BY lastactiontime @@ -567,7 +567,7 @@ class MyForm(QtGui.QMainWindow): while self.ui.tableWidgetSent.rowCount() > 0: self.ui.tableWidgetSent.removeRow(0) - queryreturn = sqlQuery(sql, what) + queryreturn = sqlQuery(sqlStatement, what) for row in queryreturn: toAddress, fromAddress, subject, message, status, ackdata, lastactiontime = row subject = shared.fixPotentiallyInvalidUTF8Data(subject) @@ -678,7 +678,7 @@ class MyForm(QtGui.QMainWindow): else: where = "toaddress || fromaddress || subject || message" - sql = ''' + sqlStatement = ''' SELECT msgid, toaddress, fromaddress, subject, received, message, read FROM inbox WHERE folder="inbox" AND %s LIKE ? ORDER BY received @@ -689,7 +689,7 @@ class MyForm(QtGui.QMainWindow): font = QFont() font.setBold(True) - queryreturn = sqlQuery(sql, what) + queryreturn = sqlQuery(sqlStatement, what) for row in queryreturn: msgid, toAddress, fromAddress, subject, received, message, read = row subject = shared.fixPotentiallyInvalidUTF8Data(subject) diff --git a/src/helper_sql.py b/src/helper_sql.py index 0353f9ae..9803b2c0 100644 --- a/src/helper_sql.py +++ b/src/helper_sql.py @@ -7,6 +7,7 @@ sqlLock = threading.Lock() def sqlQuery(sqlStatement, *args): sqlLock.acquire() + print 'sqlQuery args are:', args sqlSubmitQueue.put(sqlStatement) if args == (): @@ -21,6 +22,7 @@ def sqlQuery(sqlStatement, *args): def sqlExecute(sqlStatement, *args): sqlLock.acquire() + print 'sqlExecute args are:', args sqlSubmitQueue.put(sqlStatement) if args == ():