From f70aff617bcc55d7b190cc03fa56fda1c40e8347 Mon Sep 17 00:00:00 2001 From: Kashiko Koibumi Date: Fri, 24 May 2024 12:42:29 +0900 Subject: [PATCH] use import paths compatible with both Python2 and Python3 --- src/bitmessageqt/__init__.py | 26 +++++++++++++------------- src/bitmessageqt/address_dialogs.py | 4 ++-- src/bitmessageqt/addressvalidator.py | 2 +- src/bitmessageqt/bitmessageui.py | 12 ++++++------ src/bitmessageqt/blacklist.py | 8 ++++---- src/bitmessageqt/dialogs.py | 8 ++++---- src/bitmessageqt/foldertree.py | 4 ++-- src/bitmessageqt/messageview.py | 2 +- src/bitmessageqt/networkstatus.py | 6 +++--- src/bitmessageqt/newchandialog.py | 6 +++--- src/bitmessageqt/retranslateui.py | 2 +- src/bitmessageqt/settings.py | 2 +- src/bitmessageqt/support.py | 6 +++--- src/bitmessageqt/tests/__init__.py | 8 ++++---- src/bitmessageqt/tests/addressbook.py | 2 +- src/bitmessageqt/tests/settings.py | 2 +- src/bitmessageqt/tests/support.py | 2 +- src/network/__init__.py | 2 +- src/network/addrthread.py | 4 ++-- src/network/advanceddispatcher.py | 2 +- src/network/announcethread.py | 6 +++--- src/network/bmobject.py | 4 ++-- src/network/bmproto.py | 22 +++++++++++----------- src/network/connectionchooser.py | 2 +- src/network/connectionpool.py | 14 +++++++------- src/network/dandelion.py | 2 +- src/network/downloadthread.py | 6 +++--- src/network/http.py | 10 +++++----- src/network/invthread.py | 4 ++-- src/network/networkthread.py | 4 ++-- src/network/objectracker.py | 4 ++-- src/network/proxy.py | 6 +++--- src/network/receivequeuethread.py | 4 ++-- src/network/socks4a.py | 2 +- src/network/socks5.py | 4 ++-- src/network/stats.py | 6 +++--- src/network/tcp.py | 18 +++++++++--------- src/network/udp.py | 10 +++++----- src/network/uploadthread.py | 4 ++-- 39 files changed, 121 insertions(+), 121 deletions(-) diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index a4a7bb60..1212e45a 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -23,38 +23,38 @@ import shared import state from debug import logger from tr import _translate -from account import ( +from .account import ( accountClass, getSortedSubscriptions, BMAccount, GatewayAccount, MailchuckAccount, AccountColor) from addresses import decodeAddress, addBMIfNotPresent -from bitmessageui import Ui_MainWindow +from bitmessageqt.bitmessageui import Ui_MainWindow from bmconfigparser import config 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, MessageList_TimeWidget) -import settingsmixin -import support +from bitmessageqt import settingsmixin +from bitmessageqt import support from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure import helper_addressbook import helper_search import l10n -from utils import str_broadcast_subscribers, avatarize -import dialogs +from .utils import str_broadcast_subscribers, avatarize +from bitmessageqt import dialogs from network.stats import pendingDownload, pendingUpload -from uisignaler import UISignaler +from .uisignaler import UISignaler import paths from proofofwork import getPowType import queues import shutdown -from statusbar import BMStatusBar -import sound +from .statusbar import BMStatusBar +from bitmessageqt import sound # This is needed for tray icon -import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import +from bitmessageqt import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import import helper_sent try: diff --git a/src/bitmessageqt/address_dialogs.py b/src/bitmessageqt/address_dialogs.py index caf7f687..98d3dd1c 100644 --- a/src/bitmessageqt/address_dialogs.py +++ b/src/bitmessageqt/address_dialogs.py @@ -9,9 +9,9 @@ from ver import ustr, unic from PyQt4 import QtCore, QtGui import queues -import widgets +from bitmessageqt import widgets import state -from account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass +from .account import AccountMixin, GatewayAccount, MailchuckAccount, accountClass from addresses import addBMIfNotPresent, decodeAddress, encodeVarint from bmconfigparser import config as global_config from tr import _translate diff --git a/src/bitmessageqt/addressvalidator.py b/src/bitmessageqt/addressvalidator.py index fe939266..ac23c31e 100644 --- a/src/bitmessageqt/addressvalidator.py +++ b/src/bitmessageqt/addressvalidator.py @@ -12,7 +12,7 @@ from addresses import decodeAddress, addBMIfNotPresent from bmconfigparser import config from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue from tr import _translate -from utils import str_chan +from .utils import str_chan class AddressPassPhraseValidatorMixin(object): diff --git a/src/bitmessageqt/bitmessageui.py b/src/bitmessageqt/bitmessageui.py index 961fc093..e12a7bdf 100644 --- a/src/bitmessageqt/bitmessageui.py +++ b/src/bitmessageqt/bitmessageui.py @@ -9,12 +9,12 @@ from PyQt4 import QtCore, QtGui from bmconfigparser import config -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 bitmessageqt import settingsmixin +from .networkstatus import NetworkStatus +from .blacklist import Blacklist try: _fromUtf8 = QtCore.QString.fromUtf8 diff --git a/src/bitmessageqt/blacklist.py b/src/bitmessageqt/blacklist.py index 5db3152f..0927f596 100644 --- a/src/bitmessageqt/blacklist.py +++ b/src/bitmessageqt/blacklist.py @@ -4,13 +4,13 @@ from PyQt4 import QtCore, QtGui import widgets from addresses import addBMIfNotPresent from bmconfigparser import config -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): diff --git a/src/bitmessageqt/dialogs.py b/src/bitmessageqt/dialogs.py index c8969dae..85536410 100644 --- a/src/bitmessageqt/dialogs.py +++ b/src/bitmessageqt/dialogs.py @@ -6,14 +6,14 @@ from ver import ustr from PyQt4 import QtGui import paths -import widgets -from address_dialogs import ( +from bitmessageqt import widgets +from .address_dialogs import ( AddAddressDialog, EmailGatewayDialog, NewAddressDialog, NewSubscriptionDialog, RegenerateAddressesDialog, SpecialAddressBehaviorDialog ) -from newchandialog import NewChanDialog -from settings import SettingsDialog +from .newchandialog import NewChanDialog +from .settings import SettingsDialog from tr import _translate from version import softwareVersion diff --git a/src/bitmessageqt/foldertree.py b/src/bitmessageqt/foldertree.py index 437fe314..e9fe8038 100644 --- a/src/bitmessageqt/foldertree.py +++ b/src/bitmessageqt/foldertree.py @@ -11,9 +11,9 @@ from PyQt4 import QtCore, QtGui from bmconfigparser import config 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") diff --git a/src/bitmessageqt/messageview.py b/src/bitmessageqt/messageview.py index fe58cc0f..a94b01d1 100644 --- a/src/bitmessageqt/messageview.py +++ b/src/bitmessageqt/messageview.py @@ -8,7 +8,7 @@ zoom and URL click warning popup from ver import ustr, unic from PyQt4 import QtCore, QtGui -from safehtmlparser import SafeHTMLParser +from .safehtmlparser import SafeHTMLParser from tr import _translate diff --git a/src/bitmessageqt/networkstatus.py b/src/bitmessageqt/networkstatus.py index 8dd6dea7..4a5993d2 100644 --- a/src/bitmessageqt/networkstatus.py +++ b/src/bitmessageqt/networkstatus.py @@ -9,11 +9,11 @@ from PyQt4 import QtCore, QtGui import l10n import network.stats import state -import widgets +from bitmessageqt import widgets from network import connectionpool, knownnodes -from retranslateui import RetranslateMixin +from .retranslateui import RetranslateMixin from tr import _translate -from uisignaler import UISignaler +from .uisignaler import UISignaler class NetworkStatus(QtGui.QWidget, RetranslateMixin): diff --git a/src/bitmessageqt/newchandialog.py b/src/bitmessageqt/newchandialog.py index 46e06959..72b4f273 100644 --- a/src/bitmessageqt/newchandialog.py +++ b/src/bitmessageqt/newchandialog.py @@ -7,13 +7,13 @@ src/bitmessageqt/newchandialog.py from ver import ustr, unic from PyQt4 import QtCore, QtGui -import widgets +from bitmessageqt import widgets from addresses import addBMIfNotPresent -from addressvalidator import AddressValidator, PassPhraseValidator +from .addressvalidator import AddressValidator, PassPhraseValidator from queues import ( addressGeneratorQueue, apiAddressGeneratorReturnQueue, UISignalQueue) from tr import _translate -from utils import str_chan +from .utils import str_chan class NewChanDialog(QtGui.QDialog): diff --git a/src/bitmessageqt/retranslateui.py b/src/bitmessageqt/retranslateui.py index 5b1df839..ae22e96f 100644 --- a/src/bitmessageqt/retranslateui.py +++ b/src/bitmessageqt/retranslateui.py @@ -2,7 +2,7 @@ from os import path from ver import ustr from PyQt4 import QtGui from debug import logger -import widgets +from bitmessageqt import widgets class RetranslateMixin(object): def retranslateUi(self): diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py index 50e8ebdb..14f2d30a 100644 --- a/src/bitmessageqt/settings.py +++ b/src/bitmessageqt/settings.py @@ -17,7 +17,7 @@ import openclpow import paths import queues import state -import widgets +from bitmessageqt import widgets from bmconfigparser import config as config_obj from helper_sql import sqlExecute, sqlStoredProcedure from helper_startup import start_proxyconfig diff --git a/src/bitmessageqt/support.py b/src/bitmessageqt/support.py index 8bb80b02..cb28d534 100644 --- a/src/bitmessageqt/support.py +++ b/src/bitmessageqt/support.py @@ -9,7 +9,7 @@ import time from ver import ustr, unic from PyQt4 import QtCore -import account +from bitmessageqt import account import defaults import network.stats import paths @@ -17,12 +17,12 @@ import proofofwork import queues import state from bmconfigparser import config -from foldertree import AccountMixin +from .foldertree import AccountMixin from helper_sql import sqlExecute, sqlQuery from l10n import getTranslationLanguage from openclpow import openclEnabled from pyelliptic.openssl import OpenSSL -from settings import getSOCKSProxyType +from .settings import getSOCKSProxyType from version import softwareVersion from tr import _translate diff --git a/src/bitmessageqt/tests/__init__.py b/src/bitmessageqt/tests/__init__.py index a542abdc..a81ddb04 100644 --- a/src/bitmessageqt/tests/__init__.py +++ b/src/bitmessageqt/tests/__init__.py @@ -1,9 +1,9 @@ """bitmessageqt tests""" -from addressbook import TestAddressbook -from main import TestMain, TestUISignaler -from settings import TestSettings -from support import TestSupport +from .addressbook import TestAddressbook +from .main import TestMain, TestUISignaler +from .settings import TestSettings +from .support import TestSupport __all__ = [ "TestAddressbook", "TestMain", "TestSettings", "TestSupport", diff --git a/src/bitmessageqt/tests/addressbook.py b/src/bitmessageqt/tests/addressbook.py index cd86c5d6..47d50b96 100644 --- a/src/bitmessageqt/tests/addressbook.py +++ b/src/bitmessageqt/tests/addressbook.py @@ -1,7 +1,7 @@ import helper_addressbook from bitmessageqt.support import createAddressIfNeeded -from main import TestBase +from .main import TestBase class TestAddressbook(TestBase): diff --git a/src/bitmessageqt/tests/settings.py b/src/bitmessageqt/tests/settings.py index 0dcf8cf3..e7927ea0 100644 --- a/src/bitmessageqt/tests/settings.py +++ b/src/bitmessageqt/tests/settings.py @@ -1,7 +1,7 @@ import threading import time -from main import TestBase +from .main import TestBase from bmconfigparser import config from bitmessageqt import settings diff --git a/src/bitmessageqt/tests/support.py b/src/bitmessageqt/tests/support.py index f611a0e7..8985987a 100644 --- a/src/bitmessageqt/tests/support.py +++ b/src/bitmessageqt/tests/support.py @@ -4,7 +4,7 @@ import sys from shared import isAddressInMyAddressBook -from main import TestBase +from .main import TestBase from ver import ustr diff --git a/src/network/__init__.py b/src/network/__init__.py index d89670a7..678d9f59 100644 --- a/src/network/__init__.py +++ b/src/network/__init__.py @@ -12,7 +12,7 @@ def start(config, state): """Start network threads""" import state from .announcethread import AnnounceThread - import connectionpool # pylint: disable=relative-import + from network import connectionpool from .addrthread import AddrThread from .dandelion import Dandelion from .downloadthread import DownloadThread diff --git a/src/network/addrthread.py b/src/network/addrthread.py index a0e869e3..452598e8 100644 --- a/src/network/addrthread.py +++ b/src/network/addrthread.py @@ -4,12 +4,12 @@ Announce addresses as they are received from other hosts from six.moves import queue # magic imports! -import connectionpool +from network import connectionpool from helper_random import randomshuffle from protocol import assembleAddrMessage from queues import addrQueue # FIXME: init with queue -from threads import StoppableThread +from .threads import StoppableThread class AddrThread(StoppableThread): diff --git a/src/network/advanceddispatcher.py b/src/network/advanceddispatcher.py index 49f0d19d..33c0c12e 100644 --- a/src/network/advanceddispatcher.py +++ b/src/network/advanceddispatcher.py @@ -7,7 +7,7 @@ import time import network.asyncore_pollchoose as asyncore import state -from threads import BusyError, nonBlocking +from .threads import BusyError, nonBlocking class ProcessingError(Exception): diff --git a/src/network/announcethread.py b/src/network/announcethread.py index 7cb35e77..77c7c63a 100644 --- a/src/network/announcethread.py +++ b/src/network/announcethread.py @@ -4,12 +4,12 @@ Announce myself (node address) import time # magic imports! -import connectionpool +from network import connectionpool from bmconfigparser import config from protocol import assembleAddrMessage -from node import Peer -from threads import StoppableThread +from .node import Peer +from .threads import StoppableThread class AnnounceThread(StoppableThread): diff --git a/src/network/bmobject.py b/src/network/bmobject.py index c91bf1b3..a8b0d761 100644 --- a/src/network/bmobject.py +++ b/src/network/bmobject.py @@ -6,7 +6,7 @@ import time import protocol import state -import connectionpool +import network.connectionpool # use long name to address recursive import from highlevelcrypto import calculateInventoryHash logger = logging.getLogger('default') @@ -99,7 +99,7 @@ class BMObject(object): # pylint: disable=too-many-instance-attributes logger.warning( 'The object has invalid stream: %s', self.streamNumber) raise BMObjectInvalidError() - if self.streamNumber not in connectionpool.pool.streams: + if self.streamNumber not in network.connectionpool.pool.streams: logger.debug( 'The streamNumber %i isn\'t one we are interested in.', self.streamNumber) diff --git a/src/network/bmproto.py b/src/network/bmproto.py index ed1d48c4..8e49935b 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -12,10 +12,10 @@ import time # magic imports! import addresses -import knownnodes +from network import knownnodes import protocol import state -import connectionpool +import network.connectionpool # use long name to address recursive import from bmconfigparser import config from queues import invQueue, objectProcessorQueue, portCheckerQueue from randomtrackingdict import RandomTrackingDict @@ -27,8 +27,8 @@ from network.bmobject import ( ) from network.proxy import ProxyError -from node import Node, Peer -from objectracker import ObjectTracker, missingObjects +from .node import Node, Peer +from .objectracker import ObjectTracker, missingObjects logger = logging.getLogger('default') @@ -445,7 +445,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker): for seenTime, stream, _, ip, port in self._decode_addr(): ip = str(ip) if ( - stream not in connectionpool.pool.streams + stream not in network.connectionpool.pool.streams # FIXME: should check against complete list or ip.startswith('bootstrap') ): @@ -540,7 +540,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker): if not self.isOutbound: self.append_write_buf(protocol.assembleVersionMessage( self.destination.host, self.destination.port, - connectionpool.pool.streams, True, + network.connectionpool.pool.streams, True, nodeid=self.nodeid)) logger.debug( '%(host)s:%(port)i sending version', @@ -596,7 +596,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker): 'Closed connection to %s because there is no overlapping' ' interest in streams.', self.destination) return False - if connectionpool.pool.inboundConnections.get( + if network.connectionpool.pool.inboundConnections.get( self.destination): try: if not protocol.checkSocksIP(self.destination.host): @@ -614,8 +614,8 @@ class BMProto(AdvancedDispatcher, ObjectTracker): # or server full report the same error to counter deanonymisation if ( Peer(self.destination.host, self.peerNode.port) - in connectionpool.pool.inboundConnections - or len(connectionpool.pool) + in network.connectionpool.pool.inboundConnections + or len(network.connectionpool.pool) > config.safeGetInt( 'bitmessagesettings', 'maxtotalconnections') + config.safeGetInt( @@ -627,7 +627,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker): 'Closed connection to %s due to server full' ' or duplicate inbound/outbound.', self.destination) return False - if connectionpool.pool.isAlreadyConnected(self.nonce): + if network.connectionpool.pool.isAlreadyConnected(self.nonce): self.append_write_buf(protocol.assembleErrorMessage( errorText="I'm connected to myself. Closing connection.", fatal=2)) @@ -641,7 +641,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker): @staticmethod def stopDownloadingObject(hashId, forwardAnyway=False): """Stop downloading object *hashId*""" - for connection in connectionpool.pool.connections(): + for connection in network.connectionpool.pool.connections(): try: del connection.objectsNewToMe[hashId] except KeyError: diff --git a/src/network/connectionchooser.py b/src/network/connectionchooser.py index d7062d24..f4ae075d 100644 --- a/src/network/connectionchooser.py +++ b/src/network/connectionchooser.py @@ -5,7 +5,7 @@ Select which node to connect to import logging import random -import knownnodes +from network import knownnodes import protocol import state from bmconfigparser import config diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index 36c91c18..11240506 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -8,19 +8,19 @@ import socket import sys import time -import asyncore_pollchoose as asyncore +from network import asyncore_pollchoose as asyncore import helper_random -import knownnodes +from network import knownnodes import protocol import state from bmconfigparser import config -from connectionchooser import chooseConnection -from node import Peer -from proxy import Proxy -from tcp import ( +from .connectionchooser import chooseConnection +from .node import Peer +from .proxy import Proxy +from .tcp import ( bootstrap, Socks4aBMConnection, Socks5BMConnection, TCPConnection, TCPServer) -from udp import UDPSocket +from .udp import UDPSocket logger = logging.getLogger('default') diff --git a/src/network/dandelion.py b/src/network/dandelion.py index 35e70c95..29879085 100644 --- a/src/network/dandelion.py +++ b/src/network/dandelion.py @@ -7,7 +7,7 @@ from random import choice, expovariate, sample from threading import RLock from time import time -import connectionpool +from network import connectionpool import state from queues import invQueue diff --git a/src/network/downloadthread.py b/src/network/downloadthread.py index 4f108c72..4230cca7 100644 --- a/src/network/downloadthread.py +++ b/src/network/downloadthread.py @@ -6,9 +6,9 @@ import state import addresses import helper_random import protocol -import connectionpool -from objectracker import missingObjects -from threads import StoppableThread +from network import connectionpool +from .objectracker import missingObjects +from .threads import StoppableThread class DownloadThread(StoppableThread): diff --git a/src/network/http.py b/src/network/http.py index d7a938fa..af0015c7 100644 --- a/src/network/http.py +++ b/src/network/http.py @@ -1,10 +1,10 @@ import socket -from advanceddispatcher import AdvancedDispatcher -import asyncore_pollchoose as asyncore -from proxy import ProxyError -from socks5 import Socks5Connection, Socks5Resolver -from socks4a import Socks4aConnection, Socks4aResolver +from .advanceddispatcher import AdvancedDispatcher +from network import asyncore_pollchoose as asyncore +from .proxy import ProxyError +from .socks5 import Socks5Connection, Socks5Resolver +from .socks4a import Socks4aConnection, Socks4aResolver class HttpError(ProxyError): diff --git a/src/network/invthread.py b/src/network/invthread.py index b55408d4..51224b7f 100644 --- a/src/network/invthread.py +++ b/src/network/invthread.py @@ -8,9 +8,9 @@ from time import time import addresses import protocol import state -import connectionpool +from network import connectionpool from queues import invQueue -from threads import StoppableThread +from .threads import StoppableThread def handleExpiredDandelion(expired): diff --git a/src/network/networkthread.py b/src/network/networkthread.py index 640d47a1..6a4be2a4 100644 --- a/src/network/networkthread.py +++ b/src/network/networkthread.py @@ -2,9 +2,9 @@ A thread to handle network concerns """ import network.asyncore_pollchoose as asyncore -import connectionpool +from network import connectionpool from queues import excQueue -from threads import StoppableThread +from .threads import StoppableThread class BMNetworkThread(StoppableThread): diff --git a/src/network/objectracker.py b/src/network/objectracker.py index a458e5d2..c352200d 100644 --- a/src/network/objectracker.py +++ b/src/network/objectracker.py @@ -5,7 +5,7 @@ import time from threading import RLock import state -import connectionpool +import network.connectionpool # use long name to address recursive import from randomtrackingdict import RandomTrackingDict haveBloom = False @@ -100,7 +100,7 @@ class ObjectTracker(object): def handleReceivedObject(self, streamNumber, hashid): """Handling received object""" - for i in connectionpool.pool.connections(): + for i in network.connectionpool.pool.connections(): if not i.fullyEstablished: continue try: diff --git a/src/network/proxy.py b/src/network/proxy.py index ed1af127..eb76ce97 100644 --- a/src/network/proxy.py +++ b/src/network/proxy.py @@ -6,10 +6,10 @@ import logging import socket import time -import asyncore_pollchoose as asyncore -from advanceddispatcher import AdvancedDispatcher +from network import asyncore_pollchoose as asyncore +from .advanceddispatcher import AdvancedDispatcher from bmconfigparser import config -from node import Peer +from .node import Peer logger = logging.getLogger('default') diff --git a/src/network/receivequeuethread.py b/src/network/receivequeuethread.py index 10f2acea..0e9b5d21 100644 --- a/src/network/receivequeuethread.py +++ b/src/network/receivequeuethread.py @@ -5,10 +5,10 @@ import errno import Queue import socket -import connectionpool +from network import connectionpool from network.advanceddispatcher import UnknownStateError from queues import receiveDataQueue -from threads import StoppableThread +from .threads import StoppableThread class ReceiveQueueThread(StoppableThread): diff --git a/src/network/socks4a.py b/src/network/socks4a.py index e9786168..2758838a 100644 --- a/src/network/socks4a.py +++ b/src/network/socks4a.py @@ -6,7 +6,7 @@ import logging import socket import struct -from proxy import GeneralProxyError, Proxy, ProxyError +from .proxy import GeneralProxyError, Proxy, ProxyError logger = logging.getLogger('default') diff --git a/src/network/socks5.py b/src/network/socks5.py index d1daae42..1838a737 100644 --- a/src/network/socks5.py +++ b/src/network/socks5.py @@ -7,8 +7,8 @@ import logging import socket import struct -from node import Peer -from proxy import GeneralProxyError, Proxy, ProxyError +from .node import Peer +from .proxy import GeneralProxyError, Proxy, ProxyError logger = logging.getLogger('default') diff --git a/src/network/stats.py b/src/network/stats.py index 0ab1ae0f..ea2c40c9 100644 --- a/src/network/stats.py +++ b/src/network/stats.py @@ -3,9 +3,9 @@ Network statistics """ import time -import asyncore_pollchoose as asyncore -import connectionpool -from objectracker import missingObjects +from network import asyncore_pollchoose as asyncore +from network import connectionpool +from .objectracker import missingObjects lastReceivedTimestamp = time.time() diff --git a/src/network/tcp.py b/src/network/tcp.py index 72d6a421..831a3b11 100644 --- a/src/network/tcp.py +++ b/src/network/tcp.py @@ -15,21 +15,21 @@ import helper_random import l10n import protocol import state -import connectionpool +import network.connectionpool # use long name to address recursive import from bmconfigparser import config from highlevelcrypto import randomBytes from queues import invQueue, receiveDataQueue, UISignalQueue from tr import _translate -import asyncore_pollchoose as asyncore -import knownnodes +from network import asyncore_pollchoose as asyncore +from network import knownnodes from network.advanceddispatcher import AdvancedDispatcher from network.bmproto import BMProto from network.objectracker import ObjectTracker from network.socks4a import Socks4aConnection from network.socks5 import Socks5Connection from network.tls import TLSDispatcher -from node import Peer +from .node import Peer logger = logging.getLogger('default') @@ -267,7 +267,7 @@ class TCPConnection(BMProto, TLSDispatcher): self.append_write_buf( protocol.assembleVersionMessage( self.destination.host, self.destination.port, - connectionpool.pool.streams, + network.connectionpool.pool.streams, False, nodeid=self.nodeid)) self.connectedAt = time.time() receiveDataQueue.put(self.destination) @@ -318,7 +318,7 @@ class Socks5BMConnection(Socks5Connection, TCPConnection): self.append_write_buf( protocol.assembleVersionMessage( self.destination.host, self.destination.port, - connectionpool.pool.streams, + network.connectionpool.pool.streams, False, nodeid=self.nodeid)) self.set_state("bm_header", expectBytes=protocol.Header.size) return True @@ -342,7 +342,7 @@ class Socks4aBMConnection(Socks4aConnection, TCPConnection): self.append_write_buf( protocol.assembleVersionMessage( self.destination.host, self.destination.port, - connectionpool.pool.streams, + network.connectionpool.pool.streams, False, nodeid=self.nodeid)) self.set_state("bm_header", expectBytes=protocol.Header.size) return True @@ -430,7 +430,7 @@ class TCPServer(AdvancedDispatcher): state.ownAddresses[Peer(*sock.getsockname())] = True if ( - len(connectionpool.pool) + len(network.connectionpool.pool) > config.safeGetInt( 'bitmessagesettings', 'maxtotalconnections') + config.safeGetInt( @@ -442,7 +442,7 @@ class TCPServer(AdvancedDispatcher): sock.close() return try: - connectionpool.pool.addConnection( + network.connectionpool.pool.addConnection( TCPConnection(sock=sock)) except socket.error: pass diff --git a/src/network/udp.py b/src/network/udp.py index b16146f9..e0abe110 100644 --- a/src/network/udp.py +++ b/src/network/udp.py @@ -8,12 +8,12 @@ import time # magic imports! import protocol import state -import connectionpool +import network.connectionpool # use long name to address recursive import from queues import receiveDataQueue -from bmproto import BMProto -from node import Peer -from objectracker import ObjectTracker +from .bmproto import BMProto +from .node import Peer +from .objectracker import ObjectTracker logger = logging.getLogger('default') @@ -82,7 +82,7 @@ class UDPSocket(BMProto): # pylint: disable=too-many-instance-attributes remoteport = False for seenTime, stream, _, ip, port in addresses: decodedIP = protocol.checkIPAddress(str(ip)) - if stream not in connectionpool.pool.streams: + if stream not in network.connectionpool.pool.streams: continue if (seenTime < time.time() - protocol.MAX_TIME_OFFSET or seenTime > time.time() + protocol.MAX_TIME_OFFSET): diff --git a/src/network/uploadthread.py b/src/network/uploadthread.py index 90048c0a..96794769 100644 --- a/src/network/uploadthread.py +++ b/src/network/uploadthread.py @@ -6,9 +6,9 @@ import time import helper_random import protocol import state -import connectionpool +from network import connectionpool from randomtrackingdict import RandomTrackingDict -from threads import StoppableThread +from .threads import StoppableThread class UploadThread(StoppableThread):