Runnable with both Python3 and Python2, with both PyQt5 and PyQt4 by using Qt.py #2250

Open
kashikoibumi wants to merge 127 commits from kashikoibumi/py3qt into v0.6
6 changed files with 12 additions and 12 deletions
Showing only changes of commit 5fa08f4b3b - Show all commits

View File

@ -424,7 +424,7 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderTabTreeSubscriptions(self): def rerenderTabTreeSubscriptions(self):
treeWidget = self.ui.treeWidgetSubscriptions treeWidget = self.ui.treeWidgetSubscriptions
folders = Ui_FolderWidget.folderWeight.keys() folders = Ui_FolderWidget.folderWeight.keys()
folders.remove("new") Ui_FolderWidget.folderWeight.pop("new", None)
# sort ascending when creating # sort ascending when creating
if treeWidget.topLevelItemCount() == 0: if treeWidget.topLevelItemCount() == 0:
@ -1702,7 +1702,7 @@ class MyForm(settingsmixin.SMainWindow):
addressVersionNumber, streamNumberForAddress, addressVersionNumber, streamNumberForAddress,
"regenerated deterministic address", "regenerated deterministic address",
dialog.spinBoxNumberOfAddressesToMake.value(), dialog.spinBoxNumberOfAddressesToMake.value(),
ustr(dialog.lineEditPassphrase.text()), ustr(dialog.lineEditPassphrase.text()).encode("utf-8", "replace"),
dialog.checkBoxEighteenByteRipe.isChecked() dialog.checkBoxEighteenByteRipe.isChecked()
)) ))
self.ui.tabWidget.setCurrentIndex( self.ui.tabWidget.setCurrentIndex(
@ -3770,7 +3770,7 @@ class MyForm(settingsmixin.SMainWindow):
def setAvatar(self, addressAtCurrentRow): def setAvatar(self, addressAtCurrentRow):
if not os.path.exists(state.appdata + 'avatars/'): if not os.path.exists(state.appdata + 'avatars/'):
os.makedirs(state.appdata + 'avatars/') os.makedirs(state.appdata + 'avatars/')
hash = hashlib.md5(addBMIfNotPresent(addressAtCurrentRow)).hexdigest() hash = hashlib.md5(addBMIfNotPresent(addressAtCurrentRow).encode("utf-8", "replace")).hexdigest()
extensions = [ extensions = [
'PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM', 'PNG', 'GIF', 'JPG', 'JPEG', 'SVG', 'BMP', 'MNG', 'PBM',
'PGM', 'PPM', 'TIFF', 'XBM', 'XPM', 'TGA'] 'PGM', 'PPM', 'TIFF', 'XBM', 'XPM', 'TGA']

View File

@ -153,11 +153,11 @@ class AddressPassPhraseValidatorMixin(object):
# check through generator # check through generator
if address is None: if address is None:
addressGeneratorQueue.put(('createChan', 4, 1, str_chan + ' ' + ustr(passPhrase), passPhrase, False)) addressGeneratorQueue.put(('createChan', 4, 1, str_chan + ' ' + ustr(passPhrase), passPhrase.encode("utf-8", "replace"), False))
else: else:
addressGeneratorQueue.put( addressGeneratorQueue.put(
('joinChan', addBMIfNotPresent(address), ('joinChan', addBMIfNotPresent(address),
"{} {}".format(str_chan, passPhrase), passPhrase, False)) "{} {}".format(str_chan, passPhrase), passPhrase.encode("utf-8", "replace"), False))
if self.buttonBox.button(QtGui.QDialogButtonBox.Ok).hasFocus(): if self.buttonBox.button(QtGui.QDialogButtonBox.Ok).hasFocus():
return (self.returnValid(), s, pos) return (self.returnValid(), s, pos)

View File

@ -56,13 +56,13 @@ class NewChanDialog(QtGui.QDialog):
if ustr(self.chanAddress.text()) == "": if ustr(self.chanAddress.text()) == "":
addressGeneratorQueue.put( addressGeneratorQueue.put(
('createChan', 4, 1, str_chan + ' ' + ustr(self.chanPassPhrase.text()), ('createChan', 4, 1, str_chan + ' ' + ustr(self.chanPassPhrase.text()),
ustr(self.chanPassPhrase.text()), ustr(self.chanPassPhrase.text()).encode("utf-8", "replace"),
True)) True))
else: else:
addressGeneratorQueue.put( addressGeneratorQueue.put(
('joinChan', addBMIfNotPresent(ustr(self.chanAddress.text())), ('joinChan', addBMIfNotPresent(ustr(self.chanAddress.text())),
str_chan + ' ' + ustr(self.chanPassPhrase.text()), str_chan + ' ' + ustr(self.chanPassPhrase.text()),
ustr(self.chanPassPhrase.text()), ustr(self.chanPassPhrase.text()).encode("utf-8", "replace"),
True)) True))
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True) addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
if addressGeneratorReturnValue and addressGeneratorReturnValue[0] != 'chan name does not match address': if addressGeneratorReturnValue and addressGeneratorReturnValue[0] != 'chan name does not match address':

View File

@ -38,7 +38,7 @@ def identiconize(address):
# stripped from PIL and uses QT instead (by sendiulo, same license) # stripped from PIL and uses QT instead (by sendiulo, same license)
import qidenticon import qidenticon
icon_hash = hashlib.md5( icon_hash = hashlib.md5(
addBMIfNotPresent(address) + identiconsuffix).hexdigest() (addBMIfNotPresent(address) + identiconsuffix).encode("utf-8", "replace")).hexdigest()
use_two_colors = identicon_lib[:len('qidenticon_two')] == 'qidenticon_two' use_two_colors = identicon_lib[:len('qidenticon_two')] == 'qidenticon_two'
opacity = int( opacity = int(
identicon_lib not in ( identicon_lib not in (
@ -81,7 +81,7 @@ def avatarize(address):
falls back to identiconize(address) falls back to identiconize(address)
""" """
idcon = QtGui.QIcon() idcon = QtGui.QIcon()
icon_hash = hashlib.md5(addBMIfNotPresent(address)).hexdigest() icon_hash = hashlib.md5(addBMIfNotPresent(address).encode("utf-8", "replace")).hexdigest()
if address == str_broadcast_subscribers: if address == str_broadcast_subscribers:
# don't hash [Broadcast subscribers] # don't hash [Broadcast subscribers]
icon_hash = address icon_hash = address

View File

@ -78,7 +78,7 @@ class BMConnectionPool(object):
Shortcut for combined list of connections from Shortcut for combined list of connections from
`inboundConnections` and `outboundConnections` dicts `inboundConnections` and `outboundConnections` dicts
""" """
return self.inboundConnections.values() + self.outboundConnections.values() return list(self.inboundConnections.values()) + list(self.outboundConnections.values())
def establishedConnections(self): def establishedConnections(self):
"""Shortcut for list of connections having fullyEstablished == True""" """Shortcut for list of connections having fullyEstablished == True"""
@ -388,7 +388,7 @@ class BMConnectionPool(object):
i.set_state("close") i.set_state("close")
for i in ( for i in (
self.connections() self.connections()
+ self.listeningSockets.values() + self.udpSockets.values() + list(self.listeningSockets.values()) + list(self.udpSockets.values())
): ):
if not (i.accepting or i.connecting or i.connected): if not (i.accepting or i.connecting or i.connected):
reaper.append(i) reaper.append(i)

View File

@ -95,7 +95,7 @@ def saveKnownNodes(dirName=None):
if dirName is None: if dirName is None:
dirName = state.appdata dirName = state.appdata
with knownNodesLock: with knownNodesLock:
with open(os.path.join(dirName, 'knownnodes.dat'), 'wb') as output: with open(os.path.join(dirName, 'knownnodes.dat'), 'w') as output:
json_serialize_knownnodes(output) json_serialize_knownnodes(output)