futurize --stage1 src/**/*.py -w

This commit is contained in:
Chapman Shoop 2019-08-04 15:55:52 -07:00
parent b9cd75a7de
commit 6751ff9adc
38 changed files with 140 additions and 97 deletions

View File

@ -1,3 +1,4 @@
from __future__ import print_function
# Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com> # Copyright (c) 2014 Luke Montalvo <lukemontalvo@gmail.com>
# This file adds a alternative commandline interface, feel free to critique and fork # This file adds a alternative commandline interface, feel free to critique and fork
# #

View File

@ -1,4 +1,6 @@
import kivy_helper_search from __future__ import print_function
from __future__ import absolute_import
from . import kivy_helper_search
import os import os
import queues import queues
import shutdown import shutdown
@ -308,7 +310,7 @@ class Create(Screen):
message = self.ids.message.text message = self.ids.message.text
subject = self.ids.subject.text subject = self.ids.subject.text
encoding = 3 encoding = 3
print("message: ", self.ids.message.text) print(("message: ", self.ids.message.text))
sendMessageToPeople = True sendMessageToPeople = True
if sendMessageToPeople: if sendMessageToPeople:
if toAddress != '': if toAddress != '':

View File

@ -1,6 +1,7 @@
""" """
PyQt based UI for bitmessage, the main module PyQt based UI for bitmessage, the main module
""" """
from __future__ import absolute_import
import hashlib import hashlib
import locale import locale
@ -21,41 +22,41 @@ from debug import logger
from tr import _translate from tr import _translate
from addresses import decodeAddress, addBMIfNotPresent from addresses import decodeAddress, addBMIfNotPresent
import shared import shared
from bitmessageui import Ui_MainWindow from .bitmessageui import Ui_MainWindow
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
import defaults import defaults
import namecoin import namecoin
from messageview import MessageView from .messageview import MessageView
from migrationwizard import Ui_MigrationWizard from .migrationwizard import Ui_MigrationWizard
from foldertree import ( from .foldertree import (
AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget, AccountMixin, Ui_FolderWidget, Ui_AddressWidget, Ui_SubscriptionWidget,
MessageList_AddressWidget, MessageList_SubjectWidget, MessageList_AddressWidget, MessageList_SubjectWidget,
Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress) Ui_AddressBookWidgetItemLabel, Ui_AddressBookWidgetItemAddress)
from settings import Ui_settingsDialog from .settings import Ui_settingsDialog
import settingsmixin from . import settingsmixin
import support from . import support
import debug import debug
from helper_ackPayload import genAckPayload from helper_ackPayload import genAckPayload
from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure
import helper_search import helper_search
import l10n import l10n
import openclpow import openclpow
from utils import str_broadcast_subscribers, avatarize from .utils import str_broadcast_subscribers, avatarize
from account import ( from .account import (
getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount, getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount,
GatewayAccount, MailchuckAccount, AccountColor) GatewayAccount, MailchuckAccount, AccountColor)
import dialogs from . import dialogs
from network.stats import pendingDownload, pendingUpload from network.stats import pendingDownload, pendingUpload
from uisignaler import UISignaler from .uisignaler import UISignaler
import knownnodes import knownnodes
import paths import paths
from proofofwork import getPowType from proofofwork import getPowType
import queues import queues
import shutdown import shutdown
import state import state
from statusbar import BMStatusBar from .statusbar import BMStatusBar
from network.asyncore_pollchoose import set_rates from network.asyncore_pollchoose import set_rates
import sound from . import sound
try: try:

View File

@ -3,6 +3,7 @@ src/bitmessageqt/address_dialogs.py
=================================== ===================================
""" """
from __future__ import absolute_import
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
import hashlib import hashlib
@ -10,11 +11,11 @@ import hashlib
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
import queues import queues
import widgets from . import widgets
from account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass, getSortedAccounts from .account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass, getSortedAccounts
from addresses import addBMIfNotPresent, decodeAddress, encodeVarint from addresses import addBMIfNotPresent, decodeAddress, encodeVarint
from inventory import Inventory from inventory import Inventory
from retranslateui import RetranslateMixin from .retranslateui import RetranslateMixin
from tr import _translate from tr import _translate

View File

@ -1,11 +1,12 @@
from __future__ import absolute_import
from PyQt4 import QtGui from PyQt4 import QtGui
from Queue import Empty from Queue import Empty
from addresses import decodeAddress, addBMIfNotPresent from addresses import decodeAddress, addBMIfNotPresent
from account import getSortedAccounts from .account import getSortedAccounts
from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue
from tr import _translate from tr import _translate
from utils import str_chan from .utils import str_chan
class AddressPassPhraseValidatorMixin(): class AddressPassPhraseValidatorMixin():
def setParams(self, passPhraseObject=None, addressObject=None, feedBackObject=None, buttonBox=None, addressMandatory=True): def setParams(self, passPhraseObject=None, addressObject=None, feedBackObject=None, buttonBox=None, addressMandatory=True):

View File

@ -7,14 +7,15 @@
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
from __future__ import absolute_import
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from foldertree import AddressBookCompleter from .foldertree import AddressBookCompleter
from messageview import MessageView from .messageview import MessageView
from messagecompose import MessageCompose from .messagecompose import MessageCompose
import settingsmixin from . import settingsmixin
from networkstatus import NetworkStatus from .networkstatus import NetworkStatus
from blacklist import Blacklist from .blacklist import Blacklist
try: try:
_fromUtf8 = QtCore.QString.fromUtf8 _fromUtf8 = QtCore.QString.fromUtf8
@ -771,7 +772,7 @@ class Ui_MainWindow(object):
self.actionDeleteAllTrashedMessages.setText(_translate("MainWindow", "Delete all trashed messages", None)) self.actionDeleteAllTrashedMessages.setText(_translate("MainWindow", "Delete all trashed messages", None))
self.actionJoinChan.setText(_translate("MainWindow", "Join / Create chan", None)) self.actionJoinChan.setText(_translate("MainWindow", "Join / Create chan", None))
import bitmessage_icons_rc from . import bitmessage_icons_rc
if __name__ == "__main__": if __name__ == "__main__":
import sys import sys

View File

@ -1,15 +1,16 @@
from __future__ import absolute_import
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
import widgets from . import widgets
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from dialogs import AddAddressDialog from .dialogs import AddAddressDialog
from helper_sql import sqlExecute, sqlQuery from helper_sql import sqlExecute, sqlQuery
from queues import UISignalQueue from queues import UISignalQueue
from retranslateui import RetranslateMixin from .retranslateui import RetranslateMixin
from tr import _translate from tr import _translate
from uisignaler import UISignaler from .uisignaler import UISignaler
from utils import avatarize from .utils import avatarize
class Blacklist(QtGui.QWidget, RetranslateMixin): class Blacklist(QtGui.QWidget, RetranslateMixin):

View File

@ -2,19 +2,20 @@
src/bitmessageqt/dialogs.py src/bitmessageqt/dialogs.py
=========================== ===========================
""" """
from __future__ import absolute_import
from PyQt4 import QtGui from PyQt4 import QtGui
from version import softwareVersion from version import softwareVersion
import paths import paths
import widgets from . import widgets
from address_dialogs import ( from .address_dialogs import (
AddAddressDialog, EmailGatewayDialog, NewAddressDialog, NewSubscriptionDialog, RegenerateAddressesDialog, AddAddressDialog, EmailGatewayDialog, NewAddressDialog, NewSubscriptionDialog, RegenerateAddressesDialog,
SpecialAddressBehaviorDialog SpecialAddressBehaviorDialog
) )
from newchandialog import NewChanDialog from .newchandialog import NewChanDialog
from retranslateui import RetranslateMixin from .retranslateui import RetranslateMixin
from tr import _translate from tr import _translate
__all__ = [ __all__ = [

View File

@ -2,6 +2,7 @@
src/bitmessageqt/foldertree.py src/bitmessageqt/foldertree.py
============================== ==============================
""" """
from __future__ import absolute_import
# pylint: disable=too-many-arguments,bad-super-call,attribute-defined-outside-init # pylint: disable=too-many-arguments,bad-super-call,attribute-defined-outside-init
from cgi import escape from cgi import escape
@ -10,9 +11,9 @@ from PyQt4 import QtCore, QtGui
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlQuery from helper_sql import sqlExecute, sqlQuery
from settingsmixin import SettingsMixin from .settingsmixin import SettingsMixin
from tr import _translate from tr import _translate
from utils import avatarize from .utils import avatarize
# for pylupdate # for pylupdate
_translate("MainWindow", "inbox") _translate("MainWindow", "inbox")

View File

@ -3,10 +3,11 @@ src/bitmessageqt/messageview.py
=============================== ===============================
""" """
from __future__ import absolute_import
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from safehtmlparser import SafeHTMLParser from .safehtmlparser import SafeHTMLParser
class MessageView(QtGui.QTextBrowser): class MessageView(QtGui.QTextBrowser):

View File

@ -3,6 +3,7 @@ src/bitmessageqt/networkstatus.py
================================= =================================
""" """
from __future__ import absolute_import
import time import time
@ -12,12 +13,12 @@ import knownnodes
import l10n import l10n
import network.stats import network.stats
import shared import shared
import widgets from . import widgets
from inventory import Inventory from inventory import Inventory
from network.connectionpool import BMConnectionPool from network.connectionpool import BMConnectionPool
from retranslateui import RetranslateMixin from .retranslateui import RetranslateMixin
from tr import _translate from tr import _translate
from uisignaler import UISignaler from .uisignaler import UISignaler
class NetworkStatus(QtGui.QWidget, RetranslateMixin): class NetworkStatus(QtGui.QWidget, RetranslateMixin):

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python2.7 #!/usr/bin/env python2.7
from __future__ import print_function
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
class NewAddressWizardIntroPage(QtGui.QWizardPage): class NewAddressWizardIntroPage(QtGui.QWizardPage):
@ -234,7 +235,7 @@ class NewAddressWizardWaitPage(QtGui.QWizardPage):
self.wizard().button(QtGui.QWizard.NextButton).click() self.wizard().button(QtGui.QWizard.NextButton).click()
return return
elif i == 101: elif i == 101:
print "haha" print("haha")
return return
self.progressBar.setValue(i) self.progressBar.setValue(i)
if i == 50: if i == 50:
@ -347,8 +348,8 @@ if __name__ == '__main__':
wizard = Ui_NewAddressWizard(["a", "b", "c", "d"]) wizard = Ui_NewAddressWizard(["a", "b", "c", "d"])
if (wizard.exec_()): if (wizard.exec_()):
print "Email: " + ("yes" if wizard.field("emailAsWell").toBool() else "no") print("Email: " + ("yes" if wizard.field("emailAsWell").toBool() else "no"))
print "BM: " + ("yes" if wizard.field("onlyBM").toBool() else "no") print("BM: " + ("yes" if wizard.field("onlyBM").toBool() else "no"))
else: else:
print "Wizard cancelled" print("Wizard cancelled")
sys.exit() sys.exit()

View File

@ -3,16 +3,17 @@ src/bitmessageqt/newchandialog.py
================================= =================================
""" """
from __future__ import absolute_import
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
import widgets from . import widgets
from addresses import addBMIfNotPresent from addresses import addBMIfNotPresent
from addressvalidator import AddressValidator, PassPhraseValidator from .addressvalidator import AddressValidator, PassPhraseValidator
from queues import UISignalQueue, addressGeneratorQueue, apiAddressGeneratorReturnQueue from queues import UISignalQueue, addressGeneratorQueue, apiAddressGeneratorReturnQueue
from retranslateui import RetranslateMixin from .retranslateui import RetranslateMixin
from tr import _translate from tr import _translate
from utils import str_chan from .utils import str_chan
class NewChanDialog(QtGui.QDialog, RetranslateMixin): class NewChanDialog(QtGui.QDialog, RetranslateMixin):

View File

@ -1,7 +1,8 @@
from __future__ import absolute_import
from os import path from os import path
from PyQt4 import QtGui from PyQt4 import QtGui
from debug import logger from debug import logger
import widgets from . import widgets
class RetranslateMixin(object): class RetranslateMixin(object):
def retranslateUi(self): def retranslateUi(self):

View File

@ -1,14 +1,15 @@
from __future__ import absolute_import
import ctypes import ctypes
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
import ssl import ssl
import sys import sys
import time import time
import account from . import account
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from debug import logger from debug import logger
import defaults import defaults
from foldertree import AccountMixin from .foldertree import AccountMixin
from helper_sql import * from helper_sql import *
from l10n import getTranslationLanguage from l10n import getTranslationLanguage
from openclpow import openclAvailable, openclEnabled from openclpow import openclAvailable, openclEnabled

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
from kivy.lang import Builder from kivy.lang import Builder
from kivy.uix.modalview import ModalView from kivy.uix.modalview import ModalView
from kivymd.label import MDLabel from kivymd.label import MDLabel

View File

@ -50,6 +50,7 @@ control than multi-threaded programming. The module documented here solves
many of the difficult problems for you, making the task of building many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap. sophisticated high-performance network servers and clients a snap.
""" """
from __future__ import print_function
import os import os
import select import select
@ -788,7 +789,7 @@ class dispatcher:
def log_info(self, message, log_type='info'): def log_info(self, message, log_type='info'):
"""Conditionally print a message""" """Conditionally print a message"""
if log_type not in self.ignore_log_types: if log_type not in self.ignore_log_types:
print '%s: %s' % (log_type, message) print('%s: %s' % (log_type, message))
def handle_read_event(self): def handle_read_event(self):
"""Handle a read event""" """Handle a read event"""

View File

@ -1,3 +1,4 @@
from __future__ import absolute_import
import base64 import base64
import hashlib import hashlib
import socket import socket
@ -6,7 +7,7 @@ import time
from binascii import hexlify from binascii import hexlify
import addresses import addresses
import connectionpool from . import connectionpool
import knownnodes import knownnodes
import protocol import protocol
import state import state
@ -21,7 +22,7 @@ from network.bmobject import (
BMObjectInvalidError, BMObjectAlreadyHaveError) BMObjectInvalidError, BMObjectAlreadyHaveError)
from network.node import Node from network.node import Node
from network.proxy import ProxyError from network.proxy import ProxyError
from objectracker import missingObjects, ObjectTracker from .objectracker import missingObjects, ObjectTracker
from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue
from randomtrackingdict import RandomTrackingDict from randomtrackingdict import RandomTrackingDict

View File

@ -1,22 +1,23 @@
from __future__ import absolute_import
import errno import errno
import re import re
import socket import socket
import time import time
import asyncore_pollchoose as asyncore from . import asyncore_pollchoose as asyncore
import helper_bootstrap import helper_bootstrap
import helper_random import helper_random
import knownnodes import knownnodes
import protocol import protocol
import state import state
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from connectionchooser import chooseConnection from .connectionchooser import chooseConnection
from debug import logger from debug import logger
from proxy import Proxy from .proxy import Proxy
from singleton import Singleton from singleton import Singleton
from tcp import ( from .tcp import (
TCPServer, Socks5BMConnection, Socks4aBMConnection, TCPConnection) TCPServer, Socks5BMConnection, Socks4aBMConnection, TCPConnection)
from udp import UDPSocket from .udp import UDPSocket
@Singleton @Singleton

View File

@ -1,9 +1,10 @@
from __future__ import absolute_import
from collections import namedtuple from collections import namedtuple
from random import choice, sample, expovariate from random import choice, sample, expovariate
from threading import RLock from threading import RLock
from time import time from time import time
import connectionpool from . import connectionpool
import state import state
from debug import logging from debug import logging
from queues import invQueue from queues import invQueue

View File

@ -1,15 +1,16 @@
from __future__ import absolute_import
import threading import threading
import time import time
import addresses import addresses
import helper_random import helper_random
import protocol import protocol
from dandelion import Dandelion from .dandelion import Dandelion
from debug import logger from debug import logger
from helper_threading import StoppableThread from helper_threading import StoppableThread
from inventory import Inventory from inventory import Inventory
from network.connectionpool import BMConnectionPool from network.connectionpool import BMConnectionPool
from objectracker import missingObjects from .objectracker import missingObjects
class DownloadThread(threading.Thread, StoppableThread): class DownloadThread(threading.Thread, StoppableThread):

View File

@ -1,3 +1,4 @@
from __future__ import print_function
import asyncore import asyncore
import socket import socket
import time import time
@ -43,7 +44,7 @@ if __name__ == "__main__":
if (len(asyncore.socket_map) < parallel): if (len(asyncore.socket_map) < parallel):
for i in range(parallel - len(asyncore.socket_map)): for i in range(parallel - len(asyncore.socket_map)):
HTTPClient('127.0.0.1', '/') HTTPClient('127.0.0.1', '/')
print "Active connections: %i" % (len(asyncore.socket_map)) print("Active connections: %i" % (len(asyncore.socket_map)))
asyncore.loop(count=len(asyncore.socket_map)/2) asyncore.loop(count=len(asyncore.socket_map)/2)
if requestCount % 100 == 0: if requestCount % 100 == 0:
print "Processed %i total messages" % (requestCount) print("Processed %i total messages" % (requestCount))

View File

@ -1,10 +1,12 @@
from __future__ import print_function
from __future__ import absolute_import
import socket import socket
from advanceddispatcher import AdvancedDispatcher from .advanceddispatcher import AdvancedDispatcher
import asyncore_pollchoose as asyncore from . import asyncore_pollchoose as asyncore
from proxy import Proxy, ProxyError, GeneralProxyError from .proxy import Proxy, ProxyError, GeneralProxyError
from socks5 import Socks5Connection, Socks5Resolver, Socks5AuthError, Socks5Error from .socks5 import Socks5Connection, Socks5Resolver, Socks5AuthError, Socks5Error
from socks4a import Socks4aConnection, Socks4aResolver, Socks4aError from .socks4a import Socks4aConnection, Socks4aResolver, Socks4aError
class HttpError(ProxyError): pass class HttpError(ProxyError): pass
@ -16,17 +18,17 @@ class HttpConnection(AdvancedDispatcher):
self.destination = (host, 80) self.destination = (host, 80)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect(self.destination) self.connect(self.destination)
print "connecting in background to %s:%i" % (self.destination[0], self.destination[1]) print("connecting in background to %s:%i" % (self.destination[0], self.destination[1]))
def state_init(self): def state_init(self):
self.append_write_buf("GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n" % (self.path, self.destination[0])) self.append_write_buf("GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n" % (self.path, self.destination[0]))
print "Sending %ib" % (len(self.write_buf)) print("Sending %ib" % (len(self.write_buf)))
self.set_state("http_request_sent", 0) self.set_state("http_request_sent", 0)
return False return False
def state_http_request_sent(self): def state_http_request_sent(self):
if len(self.read_buf) > 0: if len(self.read_buf) > 0:
print "Received %ib" % (len(self.read_buf)) print("Received %ib" % (len(self.read_buf)))
self.read_buf = b"" self.read_buf = b""
if not self.connected: if not self.connected:
self.set_state("close", 0) self.set_state("close", 0)
@ -59,13 +61,13 @@ if __name__ == "__main__":
for host in ("bootstrap8080.bitmessage.org", "bootstrap8444.bitmessage.org"): for host in ("bootstrap8080.bitmessage.org", "bootstrap8444.bitmessage.org"):
proxy = Socks5Resolver(host=host) proxy = Socks5Resolver(host=host)
while len(asyncore.socket_map) > 0: while len(asyncore.socket_map) > 0:
print "loop %s, len %i" % (proxy.state, len(asyncore.socket_map)) print("loop %s, len %i" % (proxy.state, len(asyncore.socket_map)))
asyncore.loop(timeout=1, count=1) asyncore.loop(timeout=1, count=1)
proxy.resolved() proxy.resolved()
proxy = Socks4aResolver(host=host) proxy = Socks4aResolver(host=host)
while len(asyncore.socket_map) > 0: while len(asyncore.socket_map) > 0:
print "loop %s, len %i" % (proxy.state, len(asyncore.socket_map)) print("loop %s, len %i" % (proxy.state, len(asyncore.socket_map)))
asyncore.loop(timeout=1, count=1) asyncore.loop(timeout=1, count=1)
proxy.resolved() proxy.resolved()

View File

@ -1,7 +1,8 @@
from __future__ import absolute_import
import asyncore import asyncore
import socket import socket
from tls import TLSHandshake from .tls import TLSHandshake
class HTTPRequestHandler(asyncore.dispatcher): class HTTPRequestHandler(asyncore.dispatcher):
response = """HTTP/1.0 200 OK\r response = """HTTP/1.0 200 OK\r

View File

@ -1,8 +1,9 @@
from __future__ import absolute_import
import asyncore import asyncore
from http import HTTPClient from .http import HTTPClient
import paths import paths
from tls import TLSHandshake from .tls import TLSHandshake
# self.sslSock = ssl.wrap_socket(self.sock, keyfile = os.path.join(paths.codePath(), 'sslkeys', 'key.pem'), certfile = os.path.join(paths.codePath(), 'sslkeys', 'cert.pem'), server_side = not self.initiatedConnection, ssl_version=ssl.PROTOCOL_TLSv1, do_handshake_on_connect=False, ciphers='AECDH-AES256-SHA') # self.sslSock = ssl.wrap_socket(self.sock, keyfile = os.path.join(paths.codePath(), 'sslkeys', 'key.pem'), certfile = os.path.join(paths.codePath(), 'sslkeys', 'cert.pem'), server_side = not self.initiatedConnection, ssl_version=ssl.PROTOCOL_TLSv1, do_handshake_on_connect=False, ciphers='AECDH-AES256-SHA')

View File

@ -1,9 +1,10 @@
from __future__ import absolute_import
import socket import socket
import time import time
import asyncore_pollchoose as asyncore from . import asyncore_pollchoose as asyncore
import state import state
from advanceddispatcher import AdvancedDispatcher from .advanceddispatcher import AdvancedDispatcher
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from debug import logger from debug import logger

View File

@ -1,7 +1,9 @@
from __future__ import print_function
from __future__ import absolute_import
import socket import socket
import struct import struct
from proxy import Proxy, ProxyError, GeneralProxyError from .proxy import Proxy, ProxyError, GeneralProxyError
class Socks4aError(ProxyError): class Socks4aError(ProxyError):
@ -135,4 +137,4 @@ class Socks4aResolver(Socks4a):
PyBitmessage, a callback needs to be implemented which hasn't PyBitmessage, a callback needs to be implemented which hasn't
been done yet. been done yet.
""" """
print "Resolved %s as %s" % (self.host, self.proxy_sock_name()) print("Resolved %s as %s" % (self.host, self.proxy_sock_name()))

View File

@ -3,12 +3,14 @@ src/network/socks5.py
===================== =====================
""" """
from __future__ import print_function
from __future__ import absolute_import
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
import socket import socket
import struct import struct
from proxy import GeneralProxyError, Proxy, ProxyError from .proxy import GeneralProxyError, Proxy, ProxyError
class Socks5AuthError(ProxyError): class Socks5AuthError(ProxyError):
@ -226,4 +228,4 @@ class Socks5Resolver(Socks5):
To use this within PyBitmessage, a callback needs to be To use this within PyBitmessage, a callback needs to be
implemented which hasn't been done yet. implemented which hasn't been done yet.
""" """
print "Resolved %s as %s" % (self.host, self.proxy_sock_name()) print("Resolved %s as %s" % (self.host, self.proxy_sock_name()))

View File

@ -1,8 +1,9 @@
from __future__ import absolute_import
import time import time
import asyncore_pollchoose as asyncore from . import asyncore_pollchoose as asyncore
from network.connectionpool import BMConnectionPool from network.connectionpool import BMConnectionPool
from objectracker import missingObjects from .objectracker import missingObjects
lastReceivedTimestamp = time.time() lastReceivedTimestamp = time.time()
lastReceivedBytes = 0 lastReceivedBytes = 0

View File

@ -3,6 +3,7 @@
src/network/tcp.py src/network/tcp.py
================== ==================
""" """
from __future__ import absolute_import
import math import math
import random import random
@ -10,8 +11,8 @@ import socket
import time import time
import addresses import addresses
import asyncore_pollchoose as asyncore from . import asyncore_pollchoose as asyncore
import connectionpool from . import connectionpool
import helper_random import helper_random
import knownnodes import knownnodes
import protocol import protocol

View File

@ -1,11 +1,12 @@
from __future__ import absolute_import
import time import time
import socket import socket
import state import state
import protocol import protocol
from bmproto import BMProto from .bmproto import BMProto
from debug import logger from debug import logger
from objectracker import ObjectTracker from .objectracker import ObjectTracker
from queues import receiveDataQueue from queues import receiveDataQueue

View File

@ -1,3 +1,5 @@
from __future__ import print_function
from __future__ import absolute_import
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from os import listdir, makedirs, path, remove, rmdir from os import listdir, makedirs, path, remove, rmdir
import string import string
@ -6,7 +8,7 @@ import time
import traceback import traceback
from paths import lookupAppdataFolder from paths import lookupAppdataFolder
from storage import InventoryStorage, InventoryItem from .storage import InventoryStorage, InventoryItem
class FilesystemInventory(InventoryStorage): class FilesystemInventory(InventoryStorage):
topDir = "inventory" topDir = "inventory"
@ -108,7 +110,7 @@ class FilesystemInventory(InventoryStorage):
newInventory[streamNumber] = {} newInventory[streamNumber] = {}
newInventory[streamNumber][hashId] = InventoryItem(objectType, streamNumber, None, expiresTime, tag) newInventory[streamNumber][hashId] = InventoryItem(objectType, streamNumber, None, expiresTime, tag)
except KeyError: except KeyError:
print "error loading %s" % (hexlify(hashId)) print("error loading %s" % (hexlify(hashId)))
pass pass
self._inventory = newInventory self._inventory = newInventory
# for i, v in self._inventory.items(): # for i, v in self._inventory.items():

View File

@ -1,3 +1,4 @@
from __future__ import absolute_import
import collections import collections
from threading import current_thread, enumerate as threadingEnumerate, RLock from threading import current_thread, enumerate as threadingEnumerate, RLock
import Queue import Queue
@ -5,7 +6,7 @@ import sqlite3
import time import time
from helper_sql import * from helper_sql import *
from storage import InventoryStorage, InventoryItem from .storage import InventoryStorage, InventoryItem
class SqliteInventory(InventoryStorage): class SqliteInventory(InventoryStorage):
def __init__(self): def __init__(self):

View File

@ -3,11 +3,12 @@
Utility configured as apinotifypath in bitmessagesettings Utility configured as apinotifypath in bitmessagesettings
when pybitmessage started in test mode. when pybitmessage started in test mode.
""" """
from __future__ import absolute_import
import sys import sys
import tempfile import tempfile
from test_process import put_signal_file from .test_process import put_signal_file
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -2,6 +2,7 @@
Tests for core and those that do not work outside Tests for core and those that do not work outside
(because of import error for example) (because of import error for example)
""" """
from __future__ import print_function
import os import os
import pickle # nosec import pickle # nosec

View File

@ -1,13 +1,14 @@
""" """
Tests using API. Tests using API.
""" """
from __future__ import absolute_import
import base64 import base64
import json import json
import time import time
import xmlrpclib # nosec import xmlrpclib # nosec
from test_process import TestProcessProto, TestProcessShutdown from .test_process import TestProcessProto, TestProcessShutdown
class TestAPIProto(TestProcessProto): class TestAPIProto(TestProcessProto):

View File

@ -1,12 +1,13 @@
""" """
Various tests for config Various tests for config
""" """
from __future__ import absolute_import
import os import os
import unittest import unittest
from pybitmessage.bmconfigparser import BMConfigParser from pybitmessage.bmconfigparser import BMConfigParser
from test_process import TestProcessProto from .test_process import TestProcessProto
class TestConfig(unittest.TestCase): class TestConfig(unittest.TestCase):

View File

@ -1,6 +1,7 @@
""" """
Common reusable code for tests and tests for pybitmessage process. Common reusable code for tests and tests for pybitmessage process.
""" """
from __future__ import print_function
import os import os
import signal import signal