Unicode characters in localtime raised and UnicodeError and prevented the qt gui from starting

This commit is contained in:
Alex Zhukov 2013-06-17 15:44:22 +04:00
parent 391df043f9
commit 751fa39447
3 changed files with 10 additions and 10 deletions

View File

@ -372,23 +372,23 @@ class MyForm(QtGui.QMainWindow):
elif status == 'msgqueued': elif status == 'msgqueued':
statusText = QtGui.QApplication.translate("MainWindow", "Queued.") statusText = QtGui.QApplication.translate("MainWindow", "Queued.")
elif status == 'msgsent': elif status == 'msgsent':
statusText = QtGui.QApplication.translate("MainWindow", "Message sent. Waiting on acknowledgement. Sent at %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(lastactiontime)))) statusText = QtGui.QApplication.translate("MainWindow", "Message sent. Waiting on acknowledgement. Sent at %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(lastactiontime)),'utf-8)'))
elif status == 'doingmsgpow': elif status == 'doingmsgpow':
statusText = QtGui.QApplication.translate("MainWindow", "Need to do work to send message. Work is queued.") statusText = QtGui.QApplication.translate("MainWindow", "Need to do work to send message. Work is queued.")
elif status == 'ackreceived': elif status == 'ackreceived':
statusText = QtGui.QApplication.translate("MainWindow", "Acknowledgement of the message received %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("MainWindow", "Acknowledgement of the message received %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))),'utf-8)'))
elif status == 'broadcastqueued': elif status == 'broadcastqueued':
statusText = QtGui.QApplication.translate("MainWindow", "Broadcast queued.") statusText = QtGui.QApplication.translate("MainWindow", "Broadcast queued.")
elif status == 'broadcastsent': elif status == 'broadcastsent':
statusText = QtGui.QApplication.translate("MainWindow", "Broadcast on %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("MainWindow", "Broadcast on %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))),'utf-8'))
elif status == 'toodifficult': elif status == 'toodifficult':
statusText = QtGui.QApplication.translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("MainWindow", "Problem: The work demanded by the recipient is more difficult than you are willing to do. %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))),'utf-8'))
elif status == 'badkey': elif status == 'badkey':
statusText = QtGui.QApplication.translate("MainWindow", "Problem: The recipient\'s encryption key is no good. Could not encrypt message. %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("MainWindow", "Problem: The recipient\'s encryption key is no good. Could not encrypt message. %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))),'utf-8'))
elif status == 'forcepow': elif status == 'forcepow':
statusText = QtGui.QApplication.translate("MainWindow", "Forced difficulty override. Send should start soon.") statusText = QtGui.QApplication.translate("MainWindow", "Forced difficulty override. Send should start soon.")
else: else:
statusText = QtGui.QApplication.translate("Unknown status: %1 %2").arg(status).arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))))) statusText = QtGui.QApplication.translate("Unknown status: %1 %2").arg(status).arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(lastactiontime))),'utf-8'))
newItem = myTableWidgetItem(statusText) newItem = myTableWidgetItem(statusText)
newItem.setToolTip(statusText) newItem.setToolTip(statusText)
newItem.setData(Qt.UserRole,QByteArray(ackdata)) newItem.setData(Qt.UserRole,QByteArray(ackdata))
@ -435,7 +435,7 @@ class MyForm(QtGui.QMainWindow):
#self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png")) #self.ui.pushButtonStatusIcon.setIcon(QIcon(":/newPrefix/images/yellowicon.png"))
self.statusbar = self.statusBar() self.statusbar = self.statusBar()
self.statusbar.insertPermanentWidget(0,self.ui.pushButtonStatusIcon) self.statusbar.insertPermanentWidget(0,self.ui.pushButtonStatusIcon)
self.ui.labelStartupTime.setText(QtGui.QApplication.translate("MainWindow", "Since startup on %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time())))))) self.ui.labelStartupTime.setText(QtGui.QApplication.translate("MainWindow", "Since startup on %1").arg(unicode(strftime(shared.config.get('bitmessagesettings', 'timeformat'),localtime(int(time.time()))),'utf-8)')))
self.numberOfMessagesProcessed = 0 self.numberOfMessagesProcessed = 0
self.numberOfBroadcastsProcessed = 0 self.numberOfBroadcastsProcessed = 0
self.numberOfPubkeysProcessed = 0 self.numberOfPubkeysProcessed = 0

View File

@ -51,7 +51,7 @@ def readDefaultKnownNodes(appdata):
for stream, storedValue in knownNodes.items(): for stream, storedValue in knownNodes.items():
for host,value in storedValue.items(): for host,value in storedValue.items():
port, storedtime = storedValue[host] port, storedtime = storedValue[host]
print host, '\t', port, '\t', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(storedtime))) print host, '\t', port, '\t', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(storedtime)),'utf-8')
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -59,7 +59,7 @@ def readPubkeys():
output = cur.fetchall() output = cur.fetchall()
for row in output: for row in output:
hash, havecorrectnonce, transmitdata, time, usedpersonally = row hash, havecorrectnonce, transmitdata, time, usedpersonally = row
print 'Hash:', hash.encode('hex'), '\tHave correct nonce:', havecorrectnonce, '\tTime first broadcast:', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(time))), '\tUsed by me personally:', usedpersonally, '\tFull pubkey message:', transmitdata.encode('hex') print 'Hash:', hash.encode('hex'), '\tHave correct nonce:', havecorrectnonce, '\tTime first broadcast:', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(time)),'utf-8'), '\tUsed by me personally:', usedpersonally, '\tFull pubkey message:', transmitdata.encode('hex')
def readInventory(): def readInventory():
print 'Printing everything in inventory table:' print 'Printing everything in inventory table:'
@ -69,7 +69,7 @@ def readInventory():
output = cur.fetchall() output = cur.fetchall()
for row in output: for row in output:
hash, objecttype, streamnumber, payload, receivedtime = row hash, objecttype, streamnumber, payload, receivedtime = row
print 'Hash:', hash.encode('hex'), objecttype, streamnumber, '\t', payload.encode('hex'), '\t', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(receivedtime))) print 'Hash:', hash.encode('hex'), objecttype, streamnumber, '\t', payload.encode('hex'), '\t', unicode(strftime('%a, %d %b %Y %I:%M %p',localtime(receivedtime)),'utf-8')
def takeInboxMessagesOutOfTrash(): def takeInboxMessagesOutOfTrash():