Compare commits

...

7 Commits

Author SHA1 Message Date
Chapman Shoop
7074a5d3df checking in python3 progress... 2019-08-17 21:24:26 -07:00
Chapman Shoop
83ccc9e39a checking in python3 progress... 2019-08-13 21:03:40 -07:00
Chapman Shoop
309fa40120 futurize --stage2 --all-imports src/**/*.py -w 2019-08-08 23:41:23 -07:00
Chapman Shoop
f4fdb94a56 fix tests in python2 2019-08-08 23:41:22 -07:00
Chapman Shoop
6751ff9adc futurize --stage1 src/**/*.py -w 2019-08-08 23:40:08 -07:00
Chapman Shoop
b9cd75a7de Add coverage report to test run. 2019-08-04 14:41:33 -07:00
Chapman Shoop
c45d781c96 Dockerfiles for testing python2/3 2019-08-04 14:17:04 -07:00
137 changed files with 3222 additions and 2296 deletions

27
Dockerfile.test_py2 Normal file
View File

@ -0,0 +1,27 @@
# Dockerfile for testing PyBitmessage with Python 2
# docker build -f Dockerfile.test_py2 .
FROM ubuntu:xenial
RUN apt-get update
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
build-essential libcap-dev python-all-dev python-setuptools virtualenv
WORKDIR /home/bitmessage
RUN ln -s src pybitmessage # tests environment
ENV VIRTUAL_ENV=/home/bitmessage/venv
RUN virtualenv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python --version
RUN pip --version
ADD requirements.txt .
RUN pip install -r requirements.txt
ADD . .
RUN python setup.py install
RUN coverage run --source=src setup.py test
RUN coverage report

28
Dockerfile.test_py3 Normal file
View File

@ -0,0 +1,28 @@
# Dockerfile for testing PyBitmessage with Python 3
# docker build -f Dockerfile.test_py3 .
FROM ubuntu:xenial
RUN apt-get update
RUN apt-get install -yq --no-install-suggests --no-install-recommends \
build-essential libcap-dev libssl-dev python3-all-dev python3-setuptools \
virtualenv
WORKDIR /home/bitmessage
RUN ln -s src pybitmessage # tests environment
ENV VIRTUAL_ENV=/home/bitmessage/venv
RUN virtualenv -p python3 $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python --version
RUN pip --version
ADD requirements.txt .
RUN pip install -r requirements.txt
ADD . .
RUN python setup.py install
RUN coverage run --source=src setup.py test
RUN coverage report

View File

@ -1,3 +1,6 @@
python_prctl
configparser
coverage
future
psutil
pycrypto
python_prctl

View File

@ -1,3 +1,7 @@
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
# Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com>
# This file adds a alternative commandline interface, feel free to critique and fork
#
@ -7,9 +11,17 @@
# * python2-pythondialog
# * dialog
from future import standard_library
standard_library.install_aliases()
from builtins import chr
from builtins import ascii
from builtins import str
from builtins import range
from builtins import *
from builtins import object
import os
import sys
import StringIO
import io
from textwrap import *
import time
@ -23,7 +35,7 @@ from helper_sql import *
from helper_ackPayload import genAckPayload
from addresses import *
import ConfigParser
import configparser
from bmconfigparser import BMConfigParser
from inventory import Inventory
import l10n
@ -60,13 +72,13 @@ bwtype = "black"
BROADCAST_STR = "[Broadcast subscribers]"
class printLog:
class printLog(object):
def write(self, output):
global log
log += output
def flush(self):
pass
class errLog:
class errLog(object):
def write(self, output):
global log
log += "!"+output
@ -78,7 +90,7 @@ errlog = errLog()
def cpair(a):
r = curses.color_pair(a)
if r not in range(1, curses.COLOR_PAIRS-1):
if r not in list(range(1, curses.COLOR_PAIRS-1)):
r = curses.color_pair(0)
return r
def ascii(s):
@ -303,11 +315,11 @@ def handlech(c, stdscr):
msg = ""
for i, item in enumerate(data.split("\n")):
msg += fill(item, replace_whitespace=False)+"\n"
scrollbox(d, unicode(ascii(msg)), 30, 80)
scrollbox(d, str(ascii(msg)), 30, 80)
sqlExecute("UPDATE inbox SET read=1 WHERE msgid=?", inbox[inboxcur][0])
inbox[inboxcur][7] = 1
else:
scrollbox(d, unicode("Could not fetch message."))
scrollbox(d, str("Could not fetch message."))
elif t == "2": # Mark unread
sqlExecute("UPDATE inbox SET read=0 WHERE msgid=?", inbox[inboxcur][0])
inbox[inboxcur][7] = 0
@ -321,7 +333,7 @@ def handlech(c, stdscr):
ischan = True
break
if not addresses[i][1]:
scrollbox(d, unicode("Sending address disabled, please either enable it or choose a different address."))
scrollbox(d, str("Sending address disabled, please either enable it or choose a different address."))
return
toaddr = m[2]
if ischan:
@ -351,7 +363,7 @@ def handlech(c, stdscr):
addrbook.append([label, addr])
addrbook.reverse()
else:
scrollbox(d, unicode("The selected address is already in the Address Book."))
scrollbox(d, str("The selected address is already in the Address Book."))
elif t == "5": # Save message
set_background_title(d, "Save \""+inbox[inboxcur][5]+"\" as text file")
r, t = d.inputbox("Filename", init=inbox[inboxcur][5]+".txt")
@ -365,11 +377,11 @@ def handlech(c, stdscr):
fh.write(msg)
fh.close()
else:
scrollbox(d, unicode("Could not fetch message."))
scrollbox(d, str("Could not fetch message."))
elif t == "6": # Move to trash
sqlExecute("UPDATE inbox SET folder='trash' WHERE msgid=?", inbox[inboxcur][0])
del inbox[inboxcur]
scrollbox(d, unicode("Message moved to trash. There is no interface to view your trash, \nbut the message is still on disk if you are desperate to recover it."))
scrollbox(d, str("Message moved to trash. There is no interface to view your trash, \nbut the message is still on disk if you are desperate to recover it."))
elif menutab == 2:
a = ""
if addresses[addrcur][3] != 0: # if current address is a chan
@ -392,13 +404,13 @@ def handlech(c, stdscr):
msg = ""
for i, item in enumerate(data.split("\n")):
msg += fill(item, replace_whitespace=False)+"\n"
scrollbox(d, unicode(ascii(msg)), 30, 80)
scrollbox(d, str(ascii(msg)), 30, 80)
else:
scrollbox(d, unicode("Could not fetch message."))
scrollbox(d, str("Could not fetch message."))
elif t == "2": # Move to trash
sqlExecute("UPDATE sent SET folder='trash' WHERE subject=? AND ackdata=?", sentbox[sentcur][4], sentbox[sentcur][6])
del sentbox[sentcur]
scrollbox(d, unicode("Message moved to trash. There is no interface to view your trash, \nbut the message is still on disk if you are desperate to recover it."))
scrollbox(d, str("Message moved to trash. There is no interface to view your trash, \nbut the message is still on disk if you are desperate to recover it."))
elif menutab == 4:
set_background_title(d, "Your Identities Dialog Box")
if len(addresses) <= addrcur:
@ -416,7 +428,7 @@ def handlech(c, stdscr):
if r == d.DIALOG_OK:
if t == "1": # Create new address
set_background_title(d, "Create new address")
scrollbox(d, unicode("Here you may generate as many addresses as you like.\n"
scrollbox(d, str("Here you may generate as many addresses as you like.\n"
"Indeed, creating and abandoning addresses is encouraged.\n"
"Deterministic addresses have several pros and cons:\n"
"\nPros:\n"
@ -474,12 +486,12 @@ def handlech(c, stdscr):
choices=[("1", "Spend time shortening the address", 1 if shorten else 0)])
if r == d.DIALOG_OK and "1" in t:
shorten = True
scrollbox(d, unicode("In addition to your passphrase, be sure to remember the following numbers:\n"
scrollbox(d, str("In addition to your passphrase, be sure to remember the following numbers:\n"
"\n * Address version number: "+str(4)+"\n"
" * Stream number: "+str(stream)))
queues.addressGeneratorQueue.put(('createDeterministicAddresses', 4, stream, "unused deterministic address", number, str(passphrase), shorten))
else:
scrollbox(d, unicode("Passphrases do not match"))
scrollbox(d, str("Passphrases do not match"))
elif t == "2": # Send a message
a = ""
if addresses[addrcur][3] != 0: # if current address is a chan
@ -527,7 +539,7 @@ def handlech(c, stdscr):
a = addresses[addrcur][2]
set_background_title(d, "Special address behavior")
if BMConfigParser().safeGetBoolean(a, "chan"):
scrollbox(d, unicode("This is a chan address. You cannot use it as a pseudo-mailing list."))
scrollbox(d, str("This is a chan address. You cannot use it as a pseudo-mailing list."))
else:
m = BMConfigParser().safeGetBoolean(a, "mailinglist")
r, t = d.radiolist("Select address behavior",
@ -543,7 +555,7 @@ def handlech(c, stdscr):
elif t == "2" and m == False:
try:
mn = BMConfigParser().get(a, "mailinglistname")
except ConfigParser.NoOptionError:
except configparser.NoOptionError:
mn = ""
r, t = d.inputbox("Mailing list name", init=mn)
if r == d.DIALOG_OK:
@ -632,7 +644,7 @@ def handlech(c, stdscr):
addrbook.append([t, addr])
addrbook.reverse()
else:
scrollbox(d, unicode("The selected address is already in the Address Book."))
scrollbox(d, str("The selected address is already in the Address Book."))
elif t == "4":
r, t = d.inputbox("Type in \"I want to delete this Address Book entry\"")
if r == d.DIALOG_OK and t == "I want to delete this Address Book entry":
@ -771,20 +783,20 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
err += "Some data encoded in the address is malformed. There might be something wrong with the software of your acquaintance."
else:
err += "It is unknown what is wrong with the address."
scrollbox(d, unicode(err))
scrollbox(d, str(err))
else:
addr = addBMIfNotPresent(addr)
if version > 4 or version <= 1:
set_background_title(d, "Recipient address error")
scrollbox(d, unicode("Could not understand version number " + version + "of address" + addr + "."))
scrollbox(d, str("Could not understand version number " + version + "of address" + addr + "."))
continue
if stream > 1 or stream == 0:
set_background_title(d, "Recipient address error")
scrollbox(d, unicode("Bitmessage currently only supports stream numbers of 1, unlike as requested for address " + addr + "."))
scrollbox(d, str("Bitmessage currently only supports stream numbers of 1, unlike as requested for address " + addr + "."))
continue
if not network.stats.connectedHostsList():
set_background_title(d, "Not connected warning")
scrollbox(d, unicode("Because you are not currently connected to the network, "))
scrollbox(d, str("Because you are not currently connected to the network, "))
stealthLevel = BMConfigParser().safeGetInt('bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(streamNumber, stealthLevel)
sqlExecute(
@ -808,7 +820,7 @@ def sendMessage(sender="", recv="", broadcast=None, subject="", body="", reply=F
else: # Broadcast
if recv == "":
set_background_title(d, "Empty sender error")
scrollbox(d, unicode("You must specify an address to send the message from."))
scrollbox(d, str("You must specify an address to send the message from."))
else:
# dummy ackdata, no need for stealth
ackdata = genAckPayload(streamNumber, 0)

View File

@ -1,3 +1,10 @@
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from builtins import *
from helper_sql import *

View File

@ -1,4 +1,11 @@
import kivy_helper_search
from __future__ import print_function
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import division
from future import standard_library
standard_library.install_aliases()
from builtins import *
from . import kivy_helper_search
import os
import queues
import shutdown
@ -308,7 +315,7 @@ class Create(Screen):
message = self.ids.message.text
subject = self.ids.subject.text
encoding = 3
print("message: ", self.ids.message.text)
print(("message: ", self.ids.message.text))
sendMessageToPeople = True
if sendMessageToPeople:
if toAddress != '':

View File

@ -53,8 +53,7 @@ from bmconfigparser import BMConfigParser
from inventory import Inventory
from network.connectionpool import BMConnectionPool
from network.dandelion import Dandelion
from network.fix_circular_imports import BMConnectionPool, Dandelion
from network.networkthread import BMNetworkThread
from network.receivequeuethread import ReceiveQueueThread
from network.announcethread import AnnounceThread
@ -472,8 +471,8 @@ class Main:
# signal.signal(signal.SIGINT, signal.SIG_DFL)
def usage(self):
print 'Usage: ' + sys.argv[0] + ' [OPTIONS]'
print '''
print('Usage: ' + sys.argv[0] + ' [OPTIONS]')
print('''
Options:
-h, --help show this help message and exit
-c, --curses use curses (text mode) interface
@ -482,6 +481,7 @@ Options:
All parameters are optional.
'''
)
def stop(self):
with shared.printLock:

View File

@ -1,7 +1,17 @@
"""
PyQt based UI for bitmessage, the main module
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import range
from builtins import *
from past.utils import old_div
import hashlib
import locale
import os
@ -21,41 +31,41 @@ from debug import logger
from tr import _translate
from addresses import decodeAddress, addBMIfNotPresent
import shared
from bitmessageui import Ui_MainWindow
from .bitmessageui import Ui_MainWindow
from bmconfigparser import BMConfigParser
import defaults
import namecoin
from messageview import MessageView
from migrationwizard import Ui_MigrationWizard
from foldertree import (
from .messageview import MessageView
from .migrationwizard import Ui_MigrationWizard
from .foldertree import (
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget,
MessageList_AddressWidget, MessageList_SubjectWidget,
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress)
from settings import Ui_settingsDialog
import settingsmixin
import support
from .settings import Ui_settingsDialog
from . import settingsmixin
from . import support
import debug
from helper_ackPayload import genAckPayload
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
import helper_search
import l10n
import openclpow
from utils import str_broadcast_subscribers, avatarize
from account import (
from .utils import str_broadcast_subscribers, avatarize
from .account import (
getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount,
GatewayAccount, MailchuckAccount, AccountColor)
import dialogs
from . import dialogs
from network.stats import pendingDownload, pendingUpload
from uisignaler import UISignaler
from .uisignaler import UISignaler
import knownnodes
import paths
from proofofwork import getPowType
import queues
import shutdown
import state
from statusbar import BMStatusBar
from .statusbar import BMStatusBar
from network.asyncore_pollchoose import set_rates
import sound
from . import sound
try:
@ -404,7 +414,7 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderTabTreeSubscriptions(self):
treeWidget = self.ui.treeWidgetSubscriptions
folders = Ui_FolderWidget.folderWeight.keys()
folders = list(Ui_FolderWidget.folderWeight.keys())
folders.remove("new")
# sort ascending when creating
@ -452,7 +462,7 @@ class MyForm(settingsmixin.SMainWindow):
# add missing folders
if len(db[toAddress]) > 0:
j = 0
for f, c in db[toAddress].iteritems():
for f, c in db[toAddress].items():
try:
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c['count'])
except KeyError:
@ -491,7 +501,7 @@ class MyForm(settingsmixin.SMainWindow):
treeWidget = self.ui.treeWidgetYourIdentities
elif tab == 'chan':
treeWidget = self.ui.treeWidgetChans
folders = Ui_FolderWidget.folderWeight.keys()
folders = list(Ui_FolderWidget.folderWeight.keys())
# sort ascending when creating
if treeWidget.topLevelItemCount() == 0:
@ -572,7 +582,7 @@ class MyForm(settingsmixin.SMainWindow):
# add missing folders
if len(db[toAddress]) > 0:
j = 0
for f, c in db[toAddress].iteritems():
for f, c in db[toAddress].items():
if toAddress is not None and tab == 'messages' and folder == "new":
continue
subwidget = Ui_FolderWidget(widget, j, toAddress, f, c)
@ -835,7 +845,7 @@ class MyForm(settingsmixin.SMainWindow):
BMConfigParser().save()
def updateHumanFriendlyTTLDescription(self, TTL):
numberOfHours = int(round(TTL / (60*60)))
numberOfHours = int(round(old_div(TTL, (60*60))))
font = QtGui.QFont()
stylesheet = ""
@ -848,7 +858,7 @@ class MyForm(settingsmixin.SMainWindow):
stylesheet = "QLabel { color : red; }"
font.setBold(True)
else:
numberOfDays = int(round(TTL / (24*60*60)))
numberOfDays = int(round(old_div(TTL, (24*60*60))))
self.ui.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n day(s)", None, QtCore.QCoreApplication.CodecForTr, numberOfDays))
font.setBold(False)
self.ui.labelHumanFriendlyTTLDescription.setStyleSheet(stylesheet)
@ -955,7 +965,7 @@ class MyForm(settingsmixin.SMainWindow):
# rrow = related.row(msgid), msgid should be QTableWidgetItem
# related = related.findItems(msgid, QtCore.Qt.MatchExactly),
# returns an empty list
for rrow in xrange(related.rowCount()):
for rrow in range(related.rowCount()):
if msgid == str(related.item(rrow, 3).data(
QtCore.Qt.UserRole).toPyObject()):
break
@ -1022,7 +1032,7 @@ class MyForm(settingsmixin.SMainWindow):
for i in range(root.childCount()):
addressItem = root.child(i)
if addressItem.type == AccountMixin.ALL:
newCount = sum(totalUnread.itervalues())
newCount = sum(totalUnread.values())
self.drawTrayIcon(self.currentTrayIconFileName, newCount)
else:
try:
@ -1030,7 +1040,7 @@ class MyForm(settingsmixin.SMainWindow):
broadcastsUnread
if addressItem.type == AccountMixin.SUBSCRIPTION
else normalUnread
)[addressItem.address].itervalues())
)[addressItem.address].values())
except KeyError:
newCount = 0
if newCount != addressItem.unreadCount:
@ -1073,9 +1083,9 @@ class MyForm(settingsmixin.SMainWindow):
acct.parseMessage(toAddress, fromAddress, subject, "")
items = []
MessageList_AddressWidget(items, str(toAddress), unicode(acct.toLabel, 'utf-8'))
MessageList_AddressWidget(items, str(fromAddress), unicode(acct.fromLabel, 'utf-8'))
MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'))
MessageList_AddressWidget(items, str(toAddress), str(acct.toLabel, 'utf-8'))
MessageList_AddressWidget(items, str(fromAddress), str(acct.fromLabel, 'utf-8'))
MessageList_SubjectWidget(items, str(subject), str(acct.subject, 'utf-8', 'replace'))
if status == 'awaitingpubkey':
statusText = _translate(
@ -1144,11 +1154,11 @@ class MyForm(settingsmixin.SMainWindow):
items = []
#to
MessageList_AddressWidget(items, toAddress, unicode(acct.toLabel, 'utf-8'), not read)
MessageList_AddressWidget(items, toAddress, str(acct.toLabel, 'utf-8'), not read)
# from
MessageList_AddressWidget(items, fromAddress, unicode(acct.fromLabel, 'utf-8'), not read)
MessageList_AddressWidget(items, fromAddress, str(acct.fromLabel, 'utf-8'), not read)
# subject
MessageList_SubjectWidget(items, str(subject), unicode(acct.subject, 'utf-8', 'replace'), not read)
MessageList_SubjectWidget(items, str(subject), str(acct.subject, 'utf-8', 'replace'), not read)
# time received
time_item = myTableWidgetItem(l10n.formatTimestamp(received))
time_item.setToolTip(l10n.formatTimestamp(received))
@ -1427,7 +1437,7 @@ class MyForm(settingsmixin.SMainWindow):
self, title, subtitle, category, label=None, icon=None):
self.playSound(category, label)
self._notifier(
unicode(title), unicode(subtitle), category, label, icon)
str(title), str(subtitle), category, label, icon)
# tree
def treeWidgetKeyPressEvent(self, event):
@ -1856,9 +1866,9 @@ class MyForm(settingsmixin.SMainWindow):
def rerenderAddressBook(self):
def addRow (address, label, type):
self.ui.tableWidgetAddressBook.insertRow(0)
newItem = Ui_AddressBookWidgetItemLabel(address, unicode(label, 'utf-8'), type)
newItem = Ui_AddressBookWidgetItemLabel(address, str(label, 'utf-8'), type)
self.ui.tableWidgetAddressBook.setItem(0, 0, newItem)
newItem = Ui_AddressBookWidgetItemAddress(address, unicode(label, 'utf-8'), type)
newItem = Ui_AddressBookWidgetItemAddress(address, str(label, 'utf-8'), type)
self.ui.tableWidgetAddressBook.setItem(0, 1, newItem)
oldRows = {}
@ -1892,13 +1902,13 @@ class MyForm(settingsmixin.SMainWindow):
completerList = []
for address in sorted(oldRows, key = lambda x: oldRows[x][2], reverse = True):
if address in newRows:
completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
completerList.append(str(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
newRows.pop(address)
else:
self.ui.tableWidgetAddressBook.removeRow(oldRows[address][2])
for address in newRows:
addRow(address, newRows[address][0], newRows[address][1])
completerList.append(unicode(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
completerList.append(str(newRows[address][0], encoding="UTF-8") + " <" + address + ">")
# sort
self.ui.tableWidgetAddressBook.sortByColumn(
@ -2010,7 +2020,7 @@ class MyForm(settingsmixin.SMainWindow):
toAddress)
if status != 'success':
try:
toAddress = unicode(toAddress, 'utf-8', 'ignore')
toAddress = str(toAddress, 'utf-8', 'ignore')
except:
pass
logger.error('Error: Could not decode recipient address ' + toAddress + ':' + status)
@ -2235,7 +2245,7 @@ class MyForm(settingsmixin.SMainWindow):
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
isMaillinglist = BMConfigParser().safeGetBoolean(addressInKeysFile, 'mailinglist')
if isEnabled and not isMaillinglist:
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
label = str(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
if label == "":
label = addressInKeysFile
self.ui.comboBoxSendFrom.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
@ -2259,7 +2269,7 @@ class MyForm(settingsmixin.SMainWindow):
addressInKeysFile, 'enabled') # I realize that this is poor programming practice but I don't care. It's easier for others to read.
isChan = BMConfigParser().safeGetBoolean(addressInKeysFile, 'chan')
if isEnabled and not isChan:
label = unicode(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
label = str(BMConfigParser().get(addressInKeysFile, 'label'), 'utf-8', 'ignore').strip()
if label == "":
label = addressInKeysFile
self.ui.comboBoxSendFromBroadcast.addItem(avatarize(addressInKeysFile), label, addressInKeysFile)
@ -2298,7 +2308,7 @@ class MyForm(settingsmixin.SMainWindow):
continue
self.addMessageListItemSent(sent, toAddress, fromAddress, subject, "msgqueued", ackdata, time.time())
self.getAccountTextedit(acct).setPlainText(unicode(message, 'utf-8', 'replace'))
self.getAccountTextedit(acct).setPlainText(str(message, 'utf-8', 'replace'))
sent.setCurrentCell(0, 0)
def displayNewInboxMessage(self, inventoryHash, toAddress, fromAddress, subject, message):
@ -2331,7 +2341,7 @@ class MyForm(settingsmixin.SMainWindow):
self.notifierShow(
_translate("MainWindow", "New Message"),
_translate("MainWindow", "From %1").arg(
unicode(acct.fromLabel, 'utf-8')),
str(acct.fromLabel, 'utf-8')),
sound.SOUND_UNKNOWN
)
if self.getCurrentAccount() is not None and ((self.getCurrentFolder(treeWidget) != "inbox" and self.getCurrentFolder(treeWidget) is not None) or self.getCurrentAccount(treeWidget) != acct.address):
@ -2879,8 +2889,8 @@ class MyForm(settingsmixin.SMainWindow):
if curWorkerQueue > 0:
self.updateStatusBar(_translate(
"MainWindow", "Waiting for PoW to finish... %1%"
).arg(50 * (maxWorkerQueue - curWorkerQueue) /
maxWorkerQueue))
).arg(old_div(50 * (maxWorkerQueue - curWorkerQueue),
maxWorkerQueue)))
time.sleep(0.5)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
@ -2908,7 +2918,7 @@ class MyForm(settingsmixin.SMainWindow):
self.updateStatusBar(_translate(
"MainWindow",
"Waiting for objects to be sent... %1%"
).arg(int(50 + 20 * (pendingUpload() / maxPendingUpload))))
).arg(int(50 + 20 * (old_div(pendingUpload(), maxPendingUpload)))))
time.sleep(0.5)
QtCore.QCoreApplication.processEvents(
QtCore.QEventLoop.AllEvents, 1000
@ -2928,7 +2938,7 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.QEventLoop.AllEvents, 1000
)
self.saveSettings()
for attr, obj in self.ui.__dict__.iteritems():
for attr, obj in self.ui.__dict__.items():
if hasattr(obj, "__class__") \
and isinstance(obj, settingsmixin.SettingsMixin):
saveMethod = getattr(obj, "saveSettings", None)
@ -2978,7 +2988,7 @@ class MyForm(settingsmixin.SMainWindow):
lines = messageText.split('\n')
totalLines = len(lines)
for i in xrange(totalLines):
for i in range(totalLines):
if 'Message ostensibly from ' in lines[i]:
lines[i] = '<p style="font-size: 12px; color: grey;">%s</span></p>' % (
lines[i])
@ -2989,7 +2999,7 @@ class MyForm(settingsmixin.SMainWindow):
lines[i] = '<br><br>'
content = ' '.join(lines) # To keep the whitespace between lines
content = shared.fixPotentiallyInvalidUTF8Data(content)
content = unicode(content, 'utf-8)')
content = str(content, 'utf-8)')
textEdit.setHtml(QtCore.QString(content))
def on_action_InboxMarkUnread(self):
@ -3172,7 +3182,7 @@ class MyForm(settingsmixin.SMainWindow):
self.setSendFromComboBox(toAddressAtCurrentInboxRow)
quotedText = self.quoted_text(
unicode(messageAtCurrentInboxRow, 'utf-8', 'replace'))
str(messageAtCurrentInboxRow, 'utf-8', 'replace'))
widget['message'].setPlainText(quotedText)
if acct.subject[0:3] in ['Re:', 'RE:']:
widget['subject'].setText(
@ -3416,7 +3426,7 @@ class MyForm(settingsmixin.SMainWindow):
return self.updateStatusBar(_translate(
"MainWindow", "No addresses selected."))
addresses_string = unicode(
addresses_string = str(
self.ui.lineEditTo.text().toUtf8(), 'utf-8')
for item in selected_items:
address_string = item.accountString()
@ -3804,7 +3814,7 @@ class MyForm(settingsmixin.SMainWindow):
text = str(tableWidget.item(currentRow, currentColumn).label)
else:
text = tableWidget.item(currentRow, currentColumn).data(QtCore.Qt.UserRole)
text = unicode(str(text), 'utf-8', 'ignore')
text = str(str(text), 'utf-8', 'ignore')
clipboard = QtGui.QApplication.clipboard()
clipboard.setText(text)
@ -3900,11 +3910,11 @@ class MyForm(settingsmixin.SMainWindow):
self.setAddressSound(widget.item(widget.currentRow(), 0).text())
def setAddressSound(self, addr):
filters = [unicode(_translate(
filters = [str(_translate(
"MainWindow", "Sound files (%s)" %
' '.join(['*%s%s' % (os.extsep, ext) for ext in sound.extensions])
))]
sourcefile = unicode(QtGui.QFileDialog.getOpenFileName(
sourcefile = str(QtGui.QFileDialog.getOpenFileName(
self, _translate("MainWindow", "Set notification sound..."),
filter=';;'.join(filters)
))
@ -3913,7 +3923,7 @@ class MyForm(settingsmixin.SMainWindow):
return
destdir = os.path.join(state.appdata, 'sounds')
destfile = unicode(addr) + os.path.splitext(sourcefile)[-1]
destfile = str(addr) + os.path.splitext(sourcefile)[-1]
destination = os.path.join(destdir, destfile)
if sourcefile == destination:
@ -4120,7 +4130,7 @@ class MyForm(settingsmixin.SMainWindow):
if item.type == AccountMixin.ALL:
return
newLabel = unicode(item.text(0), 'utf-8', 'ignore')
newLabel = str(item.text(0), 'utf-8', 'ignore')
oldLabel = item.defaultLabel()
# unchanged, do not do anything either
@ -4191,7 +4201,7 @@ class MyForm(settingsmixin.SMainWindow):
self.rerenderMessagelistToLabels()
completerList = self.ui.lineEditTo.completer().model().stringList()
for i in range(len(completerList)):
if unicode(completerList[i]).endswith(" <" + item.address + ">"):
if str(completerList[i]).endswith(" <" + item.address + ">"):
completerList[i] = item.label + " <" + item.address + ">"
self.ui.lineEditTo.completer().model().setStringList(completerList)
@ -4245,7 +4255,7 @@ class MyForm(settingsmixin.SMainWindow):
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
QtCore.QCoreApplication.setApplicationName("pybitmessageqt")
self.loadSettings()
for attr, obj in self.ui.__dict__.iteritems():
for attr, obj in self.ui.__dict__.items():
if hasattr(obj, "__class__") and \
isinstance(obj, settingsmixin.SettingsMixin):
loadMethod = getattr(obj, "loadSettings", None)

View File

@ -8,7 +8,16 @@ Account related functions.
"""
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from past.builtins import cmp
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import *
from builtins import object
import inspect
import re
import sys
@ -31,12 +40,12 @@ def getSortedAccounts():
configSections = BMConfigParser().addresses()
configSections.sort(
cmp=lambda x, y: cmp(
unicode(
str(
BMConfigParser().get(
x,
'label'),
'utf-8').lower(),
unicode(
str(
BMConfigParser().get(
y,
'label'),
@ -169,7 +178,7 @@ class BMAccount(object):
self.toAddress = toAddress
self.fromAddress = fromAddress
if isinstance(subject, unicode):
if isinstance(subject, str):
self.subject = str(subject)
else:
self.subject = subject

View File

@ -3,18 +3,27 @@ src/bitmessageqt/address_dialogs.py
===================================
"""
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
# pylint: disable=attribute-defined-outside-init
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import *
from builtins import object
import hashlib
from PyQt4 import QtCore, QtGui
import queues
import widgets
from account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass, getSortedAccounts
from . import widgets
from .account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass, getSortedAccounts
from addresses import addBMIfNotPresent, decodeAddress, encodeVarint
from inventory import Inventory
from retranslateui import RetranslateMixin
from .retranslateui import RetranslateMixin
from tr import _translate
@ -262,7 +271,7 @@ class SpecialAddressBehaviorDialog(QtGui.QDialog, RetranslateMixin):
except:
mailingListName = ''
self.lineEditMailingListName.setText(
unicode(mailingListName, 'utf-8')
str(mailingListName, 'utf-8')
)
QtGui.QWidget.resize(self, QtGui.QWidget.sizeHint(self))

View File

@ -1,13 +1,22 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import *
from builtins import object
from PyQt4 import QtGui
from Queue import Empty
from queue import Empty
from addresses import decodeAddress, addBMIfNotPresent
from account import getSortedAccounts
from .account import getSortedAccounts
from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue
from tr import _translate
from utils import str_chan
from .utils import str_chan
class AddressPassPhraseValidatorMixin():
class AddressPassPhraseValidatorMixin(object):
def setParams(self, passPhraseObject=None, addressObject=None, feedBackObject=None, buttonBox=None, addressMandatory=True):
self.addressObject = addressObject
self.passPhraseObject = passPhraseObject

View File

@ -7,9 +7,16 @@
#
# WARNING! All changes made in this file will be lost!
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from builtins import *
from PyQt4 import QtCore
qt_resource_data = "\
qt_resource_data = b"\
\x00\x00\x03\x66\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
@ -1534,7 +1541,7 @@ qt_resource_data = "\
\x82\
"
qt_resource_name = "\
qt_resource_name = b"\
\x00\x09\
\x0c\x78\x54\x88\
\x00\x6e\
@ -1639,7 +1646,7 @@ qt_resource_name = "\
\x00\x70\x00\x6e\x00\x67\
"
qt_resource_struct = "\
qt_resource_struct = b"\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\
\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x02\
\x00\x00\x00\x18\x00\x02\x00\x00\x00\x15\x00\x00\x00\x03\

View File

@ -7,14 +7,23 @@
#
# WARNING! All changes made in this file will be lost!
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
from builtins import *
from builtins import object
from past.utils import old_div
from PyQt4 import QtCore, QtGui
from bmconfigparser import BMConfigParser
from foldertree import AddressBookCompleter
from messageview import MessageView
from messagecompose import MessageCompose
import settingsmixin
from networkstatus import NetworkStatus
from blacklist import Blacklist
from .foldertree import AddressBookCompleter
from .messageview import MessageView
from .messagecompose import MessageCompose
from . import settingsmixin
from .networkstatus import NetworkStatus
from .blacklist import Blacklist
try:
_fromUtf8 = QtCore.QString.fromUtf8
@ -708,7 +717,7 @@ class Ui_MainWindow(object):
self.pushButtonTTL.setText(_translate("MainWindow", "TTL:", None))
hours = 48
try:
hours = int(BMConfigParser().getint('bitmessagesettings', 'ttl')/60/60)
hours = int(old_div(BMConfigParser().getint('bitmessagesettings', 'ttl'),60/60))
except:
pass
self.labelHumanFriendlyTTLDescription.setText(_translate("MainWindow", "%n hour(s)", None, QtCore.QCoreApplication.CodecForTr, hours))
@ -771,7 +780,7 @@ class Ui_MainWindow(object):
self.actionDeleteAllTrashedMessages.setText(_translate("MainWindow", "Delete all trashed messages", None))
self.actionJoinChan.setText(_translate("MainWindow", "Join / Create chan", None))
import bitmessage_icons_rc
from . import bitmessage_icons_rc
if __name__ == "__main__":
import sys

View File

@ -1,15 +1,23 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import *
from PyQt4 import QtCore, QtGui
import widgets
from . import widgets
from addresses import addBMIfNotPresent
from bmconfigparser import BMConfigParser
from dialogs import AddAddressDialog
from .dialogs import AddAddressDialog
from helper_sql import sqlExecute, sqlQuery
from queues import UISignalQueue
from retranslateui import RetranslateMixin
from .retranslateui import RetranslateMixin
from tr import _translate
from uisignaler import UISignaler
from utils import avatarize
from .uisignaler import UISignaler
from .utils import avatarize
class Blacklist(QtGui.QWidget, RetranslateMixin):
@ -73,7 +81,7 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
if queryreturn == []:
self.tableWidgetBlacklist.setSortingEnabled(False)
self.tableWidgetBlacklist.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(
newItem = QtGui.QTableWidgetItem(str(
self.NewBlacklistDialogInstance.lineEditLabel.text().toUtf8(), 'utf-8'))
newItem.setIcon(avatarize(address))
self.tableWidgetBlacklist.setItem(0, 0, newItem)
@ -172,7 +180,7 @@ class Blacklist(QtGui.QWidget, RetranslateMixin):
for row in queryreturn:
label, address, enabled = row
self.tableWidgetBlacklist.insertRow(0)
newItem = QtGui.QTableWidgetItem(unicode(label, 'utf-8'))
newItem = QtGui.QTableWidgetItem(str(label, 'utf-8'))
if not enabled:
newItem.setTextColor(QtGui.QColor(128, 128, 128))
newItem.setIcon(avatarize(address))

View File

@ -2,19 +2,27 @@
src/bitmessageqt/dialogs.py
===========================
"""
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import *
from PyQt4 import QtGui
from version import softwareVersion
import paths
import widgets
from address_dialogs import (
from . import widgets
from .address_dialogs import (
AddAddressDialog, EmailGatewayDialog, NewAddressDialog, NewSubscriptionDialog, RegenerateAddressesDialog,
SpecialAddressBehaviorDialog
)
from newchandialog import NewChanDialog
from retranslateui import RetranslateMixin
from .newchandialog import NewChanDialog
from .retranslateui import RetranslateMixin
from tr import _translate
__all__ = [

View File

@ -2,17 +2,27 @@
src/bitmessageqt/foldertree.py
==============================
"""
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
# pylint: disable=too-many-arguments,bad-super-call,attribute-defined-outside-init
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import range
from builtins import *
from builtins import object
from cgi import escape
from PyQt4 import QtCore, QtGui
from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlQuery
from settingsmixin import SettingsMixin
from .settingsmixin import SettingsMixin
from tr import _translate
from utils import avatarize
from .utils import avatarize
# for pylupdate
_translate("MainWindow", "inbox")
@ -122,7 +132,7 @@ class AccountMixin(object):
AccountMixin.NORMAL,
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
try:
retval = unicode(
retval = str(
BMConfigParser().get(self.address, 'label'), 'utf-8')
except Exception:
queryreturn = sqlQuery(
@ -134,12 +144,12 @@ class AccountMixin(object):
if queryreturn != []:
for row in queryreturn:
retval, = row
retval = unicode(retval, 'utf-8')
retval = str(retval, 'utf-8')
elif self.address is None or self.type == AccountMixin.ALL:
return unicode(
return str(
str(_translate("MainWindow", "All accounts")), 'utf-8')
return retval or unicode(self.address, 'utf-8')
return retval or str(self.address, 'utf-8')
class BMTreeWidgetItem(QtGui.QTreeWidgetItem, AccountMixin):
@ -230,15 +240,15 @@ class Ui_AddressWidget(BMTreeWidgetItem, SettingsMixin):
def _getLabel(self):
if self.address is None:
return unicode(_translate(
return str(_translate(
"MainWindow", "All accounts").toUtf8(), 'utf-8', 'ignore')
else:
try:
return unicode(