misc fixes to run with Python3

This commit is contained in:
Kashiko Koibumi 2024-05-28 00:12:27 +09:00
parent b9bfa51844
commit 5fa08f4b3b
No known key found for this signature in database
GPG Key ID: 8F06E069E37C40C4
6 changed files with 12 additions and 12 deletions

View File

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

View File

@ -153,11 +153,11 @@ class AddressPassPhraseValidatorMixin(object):
# check through generator
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:
addressGeneratorQueue.put(
('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():
return (self.returnValid(), s, pos)

View File

@ -56,13 +56,13 @@ class NewChanDialog(QtGui.QDialog):
if ustr(self.chanAddress.text()) == "":
addressGeneratorQueue.put(
('createChan', 4, 1, str_chan + ' ' + ustr(self.chanPassPhrase.text()),
ustr(self.chanPassPhrase.text()),
ustr(self.chanPassPhrase.text()).encode("utf-8", "replace"),
True))
else:
addressGeneratorQueue.put(
('joinChan', addBMIfNotPresent(ustr(self.chanAddress.text())),
str_chan + ' ' + ustr(self.chanPassPhrase.text()),
ustr(self.chanPassPhrase.text()),
ustr(self.chanPassPhrase.text()).encode("utf-8", "replace"),
True))
addressGeneratorReturnValue = apiAddressGeneratorReturnQueue.get(True)
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)
import qidenticon
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'
opacity = int(
identicon_lib not in (
@ -81,7 +81,7 @@ def avatarize(address):
falls back to identiconize(address)
"""
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:
# don't hash [Broadcast subscribers]
icon_hash = address

View File

@ -78,7 +78,7 @@ class BMConnectionPool(object):
Shortcut for combined list of connections from
`inboundConnections` and `outboundConnections` dicts
"""
return self.inboundConnections.values() + self.outboundConnections.values()
return list(self.inboundConnections.values()) + list(self.outboundConnections.values())
def establishedConnections(self):
"""Shortcut for list of connections having fullyEstablished == True"""
@ -388,7 +388,7 @@ class BMConnectionPool(object):
i.set_state("close")
for i in (
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):
reaper.append(i)

View File

@ -95,7 +95,7 @@ def saveKnownNodes(dirName=None):
if dirName is None:
dirName = state.appdata
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)