diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 9fa9c475..097938e3 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -12,11 +12,7 @@ The PyBitmessage startup script import os import sys -app_dir = os.path.dirname(os.path.abspath(__file__)) -os.chdir(app_dir) -sys.path.insert(0, app_dir) - - +import encodings # noqa:F401 for pyqtdeploy import depends depends.check_dependencies() @@ -40,7 +36,7 @@ from debug import logger # this should go before any threads from helper_startup import ( adjustHalfOpenConnectionsLimit, start_proxyconfig) from inventory import Inventory -from knownnodes import readKnownNodes +from network.knownnodes import readKnownNodes # Network objects and threads from network import ( BMConnectionPool, Dandelion, AddrThread, AnnounceThread, BMNetworkThread, @@ -53,6 +49,9 @@ from threads import ( addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread) +app_dir = os.path.dirname(os.path.abspath(__file__)) + + def _fixSocket(): if sys.platform.startswith('linux'): socket.SO_BINDTODEVICE = 25 diff --git a/src/bitmessageqt/__init__.py b/src/bitmessageqt/__init__.py index f01ec4f8..0b98e80e 100644 --- a/src/bitmessageqt/__init__.py +++ b/src/bitmessageqt/__init__.py @@ -17,39 +17,33 @@ from sqlite3 import register_adapter from qtpy import QtCore, QtGui, QtWidgets, QtNetwork -import shared -import state -from debug import logger -from tr import _translate -from addresses import decodeAddress, addBMIfNotPresent +import dialogs +import settingsmixin +import sound +import support +from pybitmessage import ( + helper_search, l10n, namecoin, paths, queues, shared, shutdown, state) +from pybitmessage.addresses import decodeAddress, addBMIfNotPresent +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.debug import logger +from pybitmessage.helper_ackPayload import genAckPayload +from pybitmessage.helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure +from pybitmessage.network.stats import pendingDownload, pendingUpload +from pybitmessage.proofofwork import getPowType +from pybitmessage.tr import _translate +from account import ( + getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount, + GatewayAccount, MailchuckAccount, AccountColor) from bitmessageui import Ui_MainWindow -from bmconfigparser import BMConfigParser -import namecoin -from messageview import MessageView 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 helper_ackPayload import genAckPayload -from helper_sql import sqlQuery, sqlExecute, sqlExecuteChunked, sqlStoredProcedure -import helper_search -import l10n -from utils import str_broadcast_subscribers, avatarize -from account import ( - getSortedAccounts, getSortedSubscriptions, accountClass, BMAccount, - GatewayAccount, MailchuckAccount, AccountColor) -import dialogs -from network.stats import pendingDownload, pendingUpload -from uisignaler import UISignaler -import paths -from proofofwork import getPowType -import queues -import shutdown +from messageview import MessageView from statusbar import BMStatusBar -import sound +from uisignaler import UISignaler +from utils import str_broadcast_subscribers, avatarize # This is needed for tray icon import bitmessage_icons_rc # noqa:F401 pylint: disable=unused-import diff --git a/src/bitmessageqt/account.py b/src/bitmessageqt/account.py index 31780e20..926a9afb 100644 --- a/src/bitmessageqt/account.py +++ b/src/bitmessageqt/account.py @@ -8,14 +8,14 @@ import re import sys import time -import queues -from addresses import decodeAddress -from bmconfigparser import BMConfigParser -from helper_ackPayload import genAckPayload -from helper_sql import sqlQuery, sqlExecute +from pybitmessage import queues +from pybitmessage.addresses import decodeAddress +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.helper_ackPayload import genAckPayload +from pybitmessage.helper_sql import sqlQuery, sqlExecute +from pybitmessage.tr import _translate from foldertree import AccountMixin from utils import str_broadcast_subscribers -from tr import _translate def getSortedAccounts(): diff --git a/src/bitmessageqt/address_dialogs.py b/src/bitmessageqt/address_dialogs.py index ac78d5ea..5b5719bc 100644 --- a/src/bitmessageqt/address_dialogs.py +++ b/src/bitmessageqt/address_dialogs.py @@ -8,15 +8,15 @@ import hashlib from qtpy import QtGui, QtWidgets -import queues import widgets +from pybitmessage import queues +from pybitmessage.addresses import decodeAddress, encodeVarint, addBMIfNotPresent +from pybitmessage.inventory import Inventory +from pybitmessage.tr import _translate from account import ( GatewayAccount, MailchuckAccount, AccountMixin, accountClass, getSortedAccounts ) -from addresses import decodeAddress, encodeVarint, addBMIfNotPresent -from inventory import Inventory -from tr import _translate class AddressCheckMixin(object): diff --git a/src/bitmessageqt/addressvalidator.py b/src/bitmessageqt/addressvalidator.py index 5e2f9b0a..beb1239c 100644 --- a/src/bitmessageqt/addressvalidator.py +++ b/src/bitmessageqt/addressvalidator.py @@ -7,10 +7,11 @@ from Queue import Empty from qtpy import QtGui -from addresses import decodeAddress, addBMIfNotPresent +from pybitmessage.addresses import decodeAddress, addBMIfNotPresent +from pybitmessage.queues import ( + apiAddressGeneratorReturnQueue, addressGeneratorQueue) +from pybitmessage.tr import _translate from account import getSortedAccounts -from queues import apiAddressGeneratorReturnQueue, addressGeneratorQueue -from tr import _translate from utils import str_chan diff --git a/src/bitmessageqt/bitmessageui.py b/src/bitmessageqt/bitmessageui.py index f75359ef..975c301b 100644 --- a/src/bitmessageqt/bitmessageui.py +++ b/src/bitmessageqt/bitmessageui.py @@ -1,15 +1,17 @@ # pylint: skip-file # flake8: noqa + from qtpy import QtCore, QtGui, QtWidgets -from tr import _translate -from bmconfigparser import BMConfigParser + +import settingsmixin +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.tr import _translate +from blacklist import Blacklist from foldertree import AddressBookCompleter from messageview import MessageView from messagecompose import MessageCompose -import settingsmixin from networkstatus import NetworkStatus -from blacklist import Blacklist import bitmessage_icons_rc diff --git a/src/bitmessageqt/blacklist.py b/src/bitmessageqt/blacklist.py index 6db303db..755c9e5e 100644 --- a/src/bitmessageqt/blacklist.py +++ b/src/bitmessageqt/blacklist.py @@ -1,13 +1,13 @@ from qtpy import QtCore, QtGui, QtWidgets import widgets -from addresses import addBMIfNotPresent -from bmconfigparser import BMConfigParser +from pybitmessage.addresses import addBMIfNotPresent +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.helper_sql import sqlExecute, sqlQuery +from pybitmessage.queues import UISignalQueue +from pybitmessage.tr import _translate from dialogs import AddAddressDialog -from helper_sql import sqlExecute, sqlQuery -from queues import UISignalQueue from retranslateui import RetranslateMixin -from tr import _translate from uisignaler import UISignaler from utils import avatarize diff --git a/src/bitmessageqt/dialogs.py b/src/bitmessageqt/dialogs.py index b1c9cafb..0b4e0729 100644 --- a/src/bitmessageqt/dialogs.py +++ b/src/bitmessageqt/dialogs.py @@ -4,8 +4,11 @@ All dialogs are available in this module. from qtpy import QtWidgets -import paths + import widgets +from pybitmessage import paths +from pybitmessage.tr import _translate +from pybitmessage.version import softwareVersion from address_dialogs import ( AddAddressDialog, EmailGatewayDialog, NewAddressDialog, NewSubscriptionDialog, RegenerateAddressesDialog, @@ -13,8 +16,7 @@ from address_dialogs import ( ) from newchandialog import NewChanDialog from settings import SettingsDialog -from tr import _translate -from version import softwareVersion + __all__ = [ "NewChanDialog", "AddAddressDialog", "NewAddressDialog", diff --git a/src/bitmessageqt/foldertree.py b/src/bitmessageqt/foldertree.py index 419ffc29..415d7fa9 100644 --- a/src/bitmessageqt/foldertree.py +++ b/src/bitmessageqt/foldertree.py @@ -8,10 +8,10 @@ from cgi import escape from qtpy import QtCore, QtGui, QtWidgets -from bmconfigparser import BMConfigParser -from helper_sql import sqlExecute, sqlQuery +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.helper_sql import sqlExecute, sqlQuery +from pybitmessage.tr import _translate from settingsmixin import SettingsMixin -from tr import _translate from utils import avatarize # for pylupdate diff --git a/src/bitmessageqt/languagebox.py b/src/bitmessageqt/languagebox.py index 5fa88167..e4a42ba7 100644 --- a/src/bitmessageqt/languagebox.py +++ b/src/bitmessageqt/languagebox.py @@ -5,9 +5,9 @@ import os from qtpy import QtCore, QtWidgets -import paths -from bmconfigparser import BMConfigParser -from tr import _translate +from pybitmessage import paths +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.tr import _translate class LanguageBox(QtWidgets.QComboBox): diff --git a/src/bitmessageqt/messagecompose.py b/src/bitmessageqt/messagecompose.py index a4bfccda..654e6e6e 100644 --- a/src/bitmessageqt/messagecompose.py +++ b/src/bitmessageqt/messagecompose.py @@ -1,5 +1,6 @@ from qtpy import QtCore, QtWidgets -from tr import _translate + +from pybitmessage.tr import _translate class MessageCompose(QtWidgets.QTextEdit): diff --git a/src/bitmessageqt/messageview.py b/src/bitmessageqt/messageview.py index ebf23c87..0e3e8ebb 100644 --- a/src/bitmessageqt/messageview.py +++ b/src/bitmessageqt/messageview.py @@ -6,8 +6,8 @@ zoom and URL click warning popup. from qtpy import QtCore, QtGui, QtWidgets +from pybitmessage.tr import _translate from safehtmlparser import SafeHTMLParser -from tr import _translate class MessageView(QtWidgets.QTextBrowser): diff --git a/src/bitmessageqt/networkstatus.py b/src/bitmessageqt/networkstatus.py index 505279d1..c5c88595 100644 --- a/src/bitmessageqt/networkstatus.py +++ b/src/bitmessageqt/networkstatus.py @@ -6,15 +6,12 @@ import time from qtpy import QtCore, QtGui, QtWidgets -import knownnodes -import l10n -import network.stats -import state import widgets -from inventory import Inventory -from network import BMConnectionPool +from pybitmessage import l10n, state +from pybitmessage.inventory import Inventory +from pybitmessage.network import BMConnectionPool, knownnodes, stats +from pybitmessage.tr import _translate from retranslateui import RetranslateMixin -from tr import _translate from uisignaler import UISignaler @@ -79,7 +76,7 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin): """Update the counter for number of objects to be synced""" self.labelSyncStatus.setText(_translate( "networkstatus", "Object(s) to be synced: %n", None, - network.stats.pendingDownload() + network.stats.pendingUpload())) + stats.pendingDownload() + stats.pendingUpload())) def updateNumberOfMessagesProcessed(self): """Update the counter for number of processed messages""" @@ -109,13 +106,13 @@ class NetworkStatus(QtWidgets.QWidget, RetranslateMixin): """ self.labelBytesRecvCount.setText(_translate( "networkstatus", "Down: {0}/s Total: {1}").format( - self.formatByteRate(network.stats.downloadSpeed()), - self.formatBytes(network.stats.receivedBytes()) + self.formatByteRate(stats.downloadSpeed()), + self.formatBytes(stats.receivedBytes()) )) self.labelBytesSentCount.setText(_translate( "networkstatus", "Up: {0}/s Total: {1}").format( - self.formatByteRate(network.stats.uploadSpeed()), - self.formatBytes(network.stats.sentBytes()) + self.formatByteRate(stats.uploadSpeed()), + self.formatBytes(stats.sentBytes()) )) def updateNetworkStatusTab(self, outbound, add, destination): diff --git a/src/bitmessageqt/newchandialog.py b/src/bitmessageqt/newchandialog.py index 7ab5fcb6..b73bf2d8 100644 --- a/src/bitmessageqt/newchandialog.py +++ b/src/bitmessageqt/newchandialog.py @@ -5,11 +5,11 @@ NewChanDialog class definition from qtpy import QtCore, QtWidgets import widgets -from addresses import addBMIfNotPresent -from addressvalidator import AddressValidator, PassPhraseValidator -from queues import ( +from pybitmessage.addresses import addBMIfNotPresent +from pybitmessage.queues import ( addressGeneratorQueue, apiAddressGeneratorReturnQueue, UISignalQueue) -from tr import _translate +from pybitmessage.tr import _translate +from addressvalidator import AddressValidator, PassPhraseValidator from utils import str_chan diff --git a/src/bitmessageqt/settings.py b/src/bitmessageqt/settings.py index e45aeef8..274bf55a 100644 --- a/src/bitmessageqt/settings.py +++ b/src/bitmessageqt/settings.py @@ -9,20 +9,15 @@ import tempfile from qtpy import QtCore, QtGui, QtWidgets -import debug -import defaults -import knownnodes -import namecoin -import openclpow -import paths -import queues -import state import widgets -from bmconfigparser import BMConfigParser -from helper_sql import sqlExecute, sqlStoredProcedure -from helper_startup import start_proxyconfig -from network.asyncore_pollchoose import set_rates -from tr import _translate +from pybitmessage import ( + debug, defaults, namecoin, openclpow, paths, queues, state) +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.helper_sql import sqlExecute, sqlStoredProcedure +from pybitmessage.helper_startup import start_proxyconfig +from pybitmessage.network import knownnodes +from pybitmessage.network.asyncore_pollchoose import set_rates +from pybitmessage.tr import _translate def getSOCKSProxyType(config): diff --git a/src/bitmessageqt/statusbar.py b/src/bitmessageqt/statusbar.py index 477b0d68..35cf6150 100644 --- a/src/bitmessageqt/statusbar.py +++ b/src/bitmessageqt/statusbar.py @@ -1,6 +1,7 @@ -from qtpy import QtWidgets from time import time +from qtpy import QtWidgets + class BMStatusBar(QtWidgets.QStatusBar): duration = 10000 diff --git a/src/bitmessageqt/support.py b/src/bitmessageqt/support.py index 081b86f7..cf30154b 100644 --- a/src/bitmessageqt/support.py +++ b/src/bitmessageqt/support.py @@ -7,21 +7,17 @@ import sys import time import account -import defaults -import network.stats -import paths -import proofofwork -import queues -import state -from bmconfigparser import BMConfigParser +from pybitmessage import defaults, paths, proofofwork, queues, state +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.helper_sql import sqlExecute, sqlQuery +from pybitmessage.l10n import getTranslationLanguage +from pybitmessage.network import stats +from pybitmessage.openclpow import openclEnabled +from pybitmessage.pyelliptic.openssl import OpenSSL +from pybitmessage.tr import _translate +from pybitmessage.version import softwareVersion 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 tr import _translate -from version import softwareVersion # this is BM support address going to Peter Surda @@ -157,7 +153,7 @@ def createSupportMessage(myapp): locale = getTranslationLanguage() socks = getSOCKSProxyType(BMConfigParser()) or 'N/A' upnp = BMConfigParser().safeGet('bitmessagesettings', 'upnp', 'N/A') - connectedhosts = len(network.stats.connectedHostsList()) + connectedhosts = len(stats.connectedHostsList()) myapp.ui.textEditMessage.setText(SUPPORT_MESSAGE.format( version, osname, architecture, pythonversion, opensslversion, qtapi, diff --git a/src/bitmessageqt/uisignaler.py b/src/bitmessageqt/uisignaler.py index f5e14fbf..27938bd3 100644 --- a/src/bitmessageqt/uisignaler.py +++ b/src/bitmessageqt/uisignaler.py @@ -1,8 +1,9 @@ -from qtpy import QtCore import sys -import queues -from network.node import Peer +from qtpy import QtCore + +from pybitmessage import queues +from pybitmessage.network.node import Peer class UISignaler(QtCore.QThread): diff --git a/src/bitmessageqt/utils.py b/src/bitmessageqt/utils.py index 60eba7ae..a7a50eea 100644 --- a/src/bitmessageqt/utils.py +++ b/src/bitmessageqt/utils.py @@ -3,9 +3,9 @@ import os from qtpy import QtGui -import state -from addresses import addBMIfNotPresent -from bmconfigparser import BMConfigParser +from pybitmessage import state +from pybitmessage.addresses import addBMIfNotPresent +from pybitmessage.bmconfigparser import BMConfigParser str_broadcast_subscribers = '[Broadcast subscribers]' str_chan = '[chan]' diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index 881ad6c2..a75bf586 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -17,7 +17,7 @@ import helper_inbox import helper_msgcoding import helper_sent import highlevelcrypto -import knownnodes +from network import knownnodes import l10n import protocol import queues diff --git a/src/class_singleCleaner.py b/src/class_singleCleaner.py index e322574e..c44d878b 100644 --- a/src/class_singleCleaner.py +++ b/src/class_singleCleaner.py @@ -23,7 +23,7 @@ import gc import os import time -import knownnodes +from network import knownnodes import queues import state import tr diff --git a/src/network/addrthread.py b/src/network/addrthread.py index 3bf448d8..77b26944 100644 --- a/src/network/addrthread.py +++ b/src/network/addrthread.py @@ -3,11 +3,11 @@ Announce addresses as they are received from other hosts """ import Queue -import state -from helper_random import randomshuffle -from network.assemble import assemble_addr -from network.connectionpool import BMConnectionPool -from queues import addrQueue +from pybitmessage import state +from pybitmessage.helper_random import randomshuffle +from pybitmessage.queues import addrQueue +from assemble import assemble_addr +from connectionpool import BMConnectionPool from threads import StoppableThread diff --git a/src/network/advanceddispatcher.py b/src/network/advanceddispatcher.py index 982be819..da0bff2f 100644 --- a/src/network/advanceddispatcher.py +++ b/src/network/advanceddispatcher.py @@ -6,8 +6,8 @@ import socket import threading import time -import network.asyncore_pollchoose as asyncore -import state +import asyncore_pollchoose as asyncore +from pybitmessage import state from threads import BusyError, nonBlocking diff --git a/src/network/announcethread.py b/src/network/announcethread.py index 19038ab6..d4e404ae 100644 --- a/src/network/announcethread.py +++ b/src/network/announcethread.py @@ -3,11 +3,11 @@ Announce myself (node address) """ import time -import state -from bmconfigparser import BMConfigParser -from network.assemble import assemble_addr -from network.connectionpool import BMConnectionPool -from network.udp import UDPSocket +from pybitmessage import state +from pybitmessage.bmconfigparser import BMConfigParser +from assemble import assemble_addr +from connectionpool import BMConnectionPool +from udp import UDPSocket from node import Peer from threads import StoppableThread diff --git a/src/network/assemble.py b/src/network/assemble.py index 32fad3e4..a657bea2 100644 --- a/src/network/assemble.py +++ b/src/network/assemble.py @@ -3,10 +3,10 @@ Create bitmessage protocol command packets """ import struct -import addresses -from network.constants import MAX_ADDR_COUNT -from network.node import Peer -from protocol import CreatePacket, encodeHost +from pybitmessage import addresses +from pybitmessage.protocol import CreatePacket, encodeHost +from constants import MAX_ADDR_COUNT +from node import Peer def assemble_addr(peerList): diff --git a/src/network/asyncore_pollchoose.py b/src/network/asyncore_pollchoose.py index 41757f37..440a35ae 100644 --- a/src/network/asyncore_pollchoose.py +++ b/src/network/asyncore_pollchoose.py @@ -19,7 +19,7 @@ from errno import ( ) from threading import current_thread -import helper_random +from pybitmessage import helper_random try: from errno import WSAEWOULDBLOCK diff --git a/src/network/bmobject.py b/src/network/bmobject.py index 12b997d7..15e75ba2 100644 --- a/src/network/bmobject.py +++ b/src/network/bmobject.py @@ -4,11 +4,10 @@ BMObject and it's exceptions. import logging import time -import protocol -import state -from addresses import calculateInventoryHash -from inventory import Inventory -from network.dandelion import Dandelion +from pybitmessage import protocol, state +from pybitmessage.addresses import calculateInventoryHash +from pybitmessage.inventory import Inventory +from dandelion import Dandelion logger = logging.getLogger('default') diff --git a/src/network/bmproto.py b/src/network/bmproto.py index 637e2ba7..e6547559 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -10,28 +10,26 @@ import struct import time from binascii import hexlify -import addresses import connectionpool import knownnodes -import protocol -import state -from bmconfigparser import BMConfigParser -from inventory import Inventory -from network.advanceddispatcher import AdvancedDispatcher -from network.bmobject import ( +from pybitmessage import addresses, protocol, state +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.inventory import Inventory +from pybitmessage.queues import invQueue, objectProcessorQueue, portCheckerQueue +from advanceddispatcher import AdvancedDispatcher +from bmobject import ( BMObject, BMObjectAlreadyHaveError, BMObjectExpiredError, BMObjectInsufficientPOWError, BMObjectInvalidDataError, BMObjectInvalidError, BMObjectUnwantedStreamError ) -from network.constants import ( +from constants import ( ADDRESS_ALIVE, MAX_MESSAGE_SIZE, MAX_OBJECT_COUNT, MAX_OBJECT_PAYLOAD_SIZE, MAX_TIME_OFFSET ) -from network.dandelion import Dandelion -from network.proxy import ProxyError +from dandelion import Dandelion +from proxy import ProxyError from node import Node, Peer from objectracker import ObjectTracker, missingObjects -from queues import invQueue, objectProcessorQueue, portCheckerQueue from randomtrackingdict import RandomTrackingDict logger = logging.getLogger('default') diff --git a/src/network/connectionchooser.py b/src/network/connectionchooser.py index badd98b7..18bdc26d 100644 --- a/src/network/connectionchooser.py +++ b/src/network/connectionchooser.py @@ -6,10 +6,9 @@ import logging import random # nosec import knownnodes -import protocol -import state -from bmconfigparser import BMConfigParser -from queues import Queue, portCheckerQueue +from pybitmessage import protocol, state +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.queues import Queue, portCheckerQueue logger = logging.getLogger('default') diff --git a/src/network/connectionpool.py b/src/network/connectionpool.py index 77eb58e4..67f5597b 100644 --- a/src/network/connectionpool.py +++ b/src/network/connectionpool.py @@ -9,15 +9,13 @@ import sys import time import asyncore_pollchoose as asyncore -import helper_random import knownnodes -import protocol -import state -from bmconfigparser import BMConfigParser +from pybitmessage import helper_random, protocol, state +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.singleton import Singleton from connectionchooser import chooseConnection from node import Peer from proxy import Proxy -from singleton import Singleton from tcp import ( bootstrap, Socks4aBMConnection, Socks5BMConnection, TCPConnection, TCPServer) diff --git a/src/network/dandelion.py b/src/network/dandelion.py index 03f45bd7..3b760ae3 100644 --- a/src/network/dandelion.py +++ b/src/network/dandelion.py @@ -8,9 +8,9 @@ from threading import RLock from time import time import connectionpool -import state -from queues import invQueue -from singleton import Singleton +from pybitmessage import state +from pybitmessage.queues import invQueue +from pybitmessage.singleton import Singleton # randomise routes after 600 seconds REASSIGN_INTERVAL = 600 diff --git a/src/network/downloadthread.py b/src/network/downloadthread.py index 0ae83b5b..73d7fd05 100644 --- a/src/network/downloadthread.py +++ b/src/network/downloadthread.py @@ -3,12 +3,10 @@ """ import time -import addresses -import helper_random -import protocol from dandelion import Dandelion -from inventory import Inventory -from network.connectionpool import BMConnectionPool +from pybitmessage import addresses, helper_random, protocol +from pybitmessage.inventory import Inventory +from connectionpool import BMConnectionPool from objectracker import missingObjects from threads import StoppableThread diff --git a/src/network/invthread.py b/src/network/invthread.py index e68b7692..b933a2c9 100644 --- a/src/network/invthread.py +++ b/src/network/invthread.py @@ -5,12 +5,10 @@ import Queue import random from time import time -import addresses -import protocol -import state -from network.connectionpool import BMConnectionPool -from network.dandelion import Dandelion -from queues import invQueue +from pybitmessage import addresses, protocol, state +from pybitmessage.queues import invQueue +from connectionpool import BMConnectionPool +from dandelion import Dandelion from threads import StoppableThread diff --git a/src/knownnodes.py b/src/network/knownnodes.py similarity index 98% rename from src/knownnodes.py rename to src/network/knownnodes.py index bb588fcb..1fe108ff 100644 --- a/src/knownnodes.py +++ b/src/network/knownnodes.py @@ -9,9 +9,9 @@ import pickle import threading import time -import state -from bmconfigparser import BMConfigParser -from network.node import Peer +from pybitmessage import state +from pybitmessage.bmconfigparser import BMConfigParser +from node import Peer knownNodesLock = threading.Lock() """Thread lock for knownnodes modification""" diff --git a/src/network/networkthread.py b/src/network/networkthread.py index 61ff6c09..25a40212 100644 --- a/src/network/networkthread.py +++ b/src/network/networkthread.py @@ -1,10 +1,10 @@ """ A thread to handle network concerns """ -import network.asyncore_pollchoose as asyncore -import state -from network.connectionpool import BMConnectionPool -from queues import excQueue +import asyncore_pollchoose as asyncore +from connectionpool import BMConnectionPool +from pybitmessage import state +from pybitmessage.queues import excQueue from threads import StoppableThread diff --git a/src/network/objectracker.py b/src/network/objectracker.py index ca29c023..af41dac6 100644 --- a/src/network/objectracker.py +++ b/src/network/objectracker.py @@ -4,8 +4,8 @@ Module for tracking objects import time from threading import RLock -import network.connectionpool -from network.dandelion import Dandelion +import connectionpool +from dandelion import Dandelion from randomtrackingdict import RandomTrackingDict haveBloom = False @@ -100,7 +100,7 @@ class ObjectTracker(object): def handleReceivedObject(self, streamNumber, hashid): """Handling received object""" - for i in network.connectionpool.BMConnectionPool().connections(): + for i in connectionpool.BMConnectionPool().connections(): if not i.fullyEstablished: continue try: diff --git a/src/network/proxy.py b/src/network/proxy.py index 38676d66..ff36a6e5 100644 --- a/src/network/proxy.py +++ b/src/network/proxy.py @@ -7,8 +7,8 @@ import socket import time import asyncore_pollchoose as asyncore +from pybitmessage.bmconfigparser import BMConfigParser from advanceddispatcher import AdvancedDispatcher -from bmconfigparser import BMConfigParser from node import Peer logger = logging.getLogger('default') diff --git a/src/network/randomtrackingdict.py b/src/network/randomtrackingdict.py index e87bf156..0651c2ae 100644 --- a/src/network/randomtrackingdict.py +++ b/src/network/randomtrackingdict.py @@ -5,7 +5,7 @@ import random from threading import RLock from time import time -import helper_random +from pybitmessage import helper_random class RandomTrackingDict(object): diff --git a/src/network/receivequeuethread.py b/src/network/receivequeuethread.py index bf1d8300..48d3e112 100644 --- a/src/network/receivequeuethread.py +++ b/src/network/receivequeuethread.py @@ -5,10 +5,10 @@ import errno import Queue import socket -import state -from network.advanceddispatcher import UnknownStateError -from network.connectionpool import BMConnectionPool -from queues import receiveDataQueue +from pybitmessage import state +from pybitmessage.queues import receiveDataQueue +from advanceddispatcher import UnknownStateError +from connectionpool import BMConnectionPool from threads import StoppableThread diff --git a/src/network/stats.py b/src/network/stats.py index 82e6c87f..c203418e 100644 --- a/src/network/stats.py +++ b/src/network/stats.py @@ -4,7 +4,7 @@ Network statistics import time import asyncore_pollchoose as asyncore -from network.connectionpool import BMConnectionPool +from connectionpool import BMConnectionPool from objectracker import missingObjects diff --git a/src/network/tcp.py b/src/network/tcp.py index 18fd2e1a..cb162051 100644 --- a/src/network/tcp.py +++ b/src/network/tcp.py @@ -8,27 +8,25 @@ import random import socket import time -import addresses import asyncore_pollchoose as asyncore import connectionpool -import helper_random import knownnodes -import protocol -import state -from bmconfigparser import BMConfigParser -from helper_random import randomBytes -from inventory import Inventory -from network.advanceddispatcher import AdvancedDispatcher -from network.assemble import assemble_addr -from network.bmproto import BMProto -from network.constants import MAX_OBJECT_COUNT -from network.dandelion import Dandelion -from network.objectracker import ObjectTracker -from network.socks4a import Socks4aConnection -from network.socks5 import Socks5Connection -from network.tls import TLSDispatcher +from pybitmessage import addresses, helper_random, protocol, state +from pybitmessage.bmconfigparser import BMConfigParser +from pybitmessage.helper_random import randomBytes +from pybitmessage.inventory import Inventory +from pybitmessage.queues import invQueue, receiveDataQueue, UISignalQueue +from advanceddispatcher import AdvancedDispatcher +from assemble import assemble_addr +from bmproto import BMProto +from constants import MAX_OBJECT_COUNT +from dandelion import Dandelion +from objectracker import ObjectTracker +from socks4a import Socks4aConnection +from socks5 import Socks5Connection +from tls import TLSDispatcher from node import Peer -from queues import invQueue, receiveDataQueue, UISignalQueue + logger = logging.getLogger('default') diff --git a/src/network/udp.py b/src/network/udp.py index d5f1cccd..6ab8c360 100644 --- a/src/network/udp.py +++ b/src/network/udp.py @@ -5,12 +5,12 @@ import logging import socket import time -import protocol -import state +from pybitmessage import protocol, state +from pybitmessage.queues import receiveDataQueue from bmproto import BMProto from node import Peer from objectracker import ObjectTracker -from queues import receiveDataQueue + logger = logging.getLogger('default') diff --git a/src/network/uploadthread.py b/src/network/uploadthread.py index 7d80d789..4e6d7978 100644 --- a/src/network/uploadthread.py +++ b/src/network/uploadthread.py @@ -3,11 +3,10 @@ """ import time -import helper_random -import protocol -from inventory import Inventory -from network.connectionpool import BMConnectionPool -from network.dandelion import Dandelion +from pybitmessage import helper_random, protocol +from pybitmessage.inventory import Inventory +from connectionpool import BMConnectionPool +from dandelion import Dandelion from randomtrackingdict import RandomTrackingDict from threads import StoppableThread diff --git a/src/shutdown.py b/src/shutdown.py index 819aa2da..69d03aff 100644 --- a/src/shutdown.py +++ b/src/shutdown.py @@ -8,7 +8,7 @@ import state from debug import logger from helper_sql import sqlQuery, sqlStoredProcedure from inventory import Inventory -from knownnodes import saveKnownNodes +from network.knownnodes import saveKnownNodes from network import StoppableThread from queues import ( addressGeneratorQueue, objectProcessorQueue, UISignalQueue, workerQueue) diff --git a/src/storage/filesystem.py b/src/storage/filesystem.py index b19d9272..e25258ce 100644 --- a/src/storage/filesystem.py +++ b/src/storage/filesystem.py @@ -7,7 +7,7 @@ from binascii import hexlify, unhexlify from os import listdir, makedirs, path, remove, rmdir from threading import RLock -from paths import lookupAppdataFolder +from pybitmessage.paths import lookupAppdataFolder from storage import InventoryItem, InventoryStorage diff --git a/src/storage/sqlite.py b/src/storage/sqlite.py index 0992c00e..b3a3c0f9 100644 --- a/src/storage/sqlite.py +++ b/src/storage/sqlite.py @@ -5,7 +5,8 @@ import sqlite3 import time from threading import RLock -from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery + +from pybitmessage.helper_sql import SqlBulkExecute, sqlExecute, sqlQuery from storage import InventoryItem, InventoryStorage diff --git a/src/upnp.py b/src/upnp.py index fc09a647..fab1ef0c 100644 --- a/src/upnp.py +++ b/src/upnp.py @@ -12,7 +12,7 @@ from random import randint from urlparse import urlparse from xml.dom.minidom import Document, parseString -import knownnodes +from network import knownnodes import queues import state import tr