replace print statements with logger #1688

Closed
navjotcis wants to merge 2 commits from bug-fixes14 into v0.6
25 changed files with 115 additions and 110 deletions
Showing only changes of commit b99c6fcf88 - Show all commits

View File

@ -3,11 +3,11 @@ Announce addresses as they are received from other hosts
""" """
import Queue import Queue
import state from assemble import assemble_addr
from helper_random import randomshuffle from connectionpool import BMConnectionPool
from network.assemble import assemble_addr from pybitmessage import state
from network.connectionpool import BMConnectionPool from pybitmessage.helper_random import randomshuffle
from queues import addrQueue from pybitmessage.queues import addrQueue
from threads import StoppableThread from threads import StoppableThread

View File

@ -6,8 +6,8 @@ import socket
import threading import threading
import time import time
import network.asyncore_pollchoose as asyncore import asyncore_pollchoose as asyncore
import state from pybitmessage import state
from threads import BusyError, nonBlocking from threads import BusyError, nonBlocking

View File

@ -3,13 +3,13 @@ Announce myself (node address)
""" """
import time import time
import state from assemble import assemble_addr
from bmconfigparser import BMConfigParser from connectionpool import BMConnectionPool
from network.assemble import assemble_addr
from network.connectionpool import BMConnectionPool
from network.udp import UDPSocket
from node import Peer from node import Peer
from pybitmessage import state
from pybitmessage.bmconfigparser import BMConfigParser
from threads import StoppableThread from threads import StoppableThread
from udp import UDPSocket
class AnnounceThread(StoppableThread): class AnnounceThread(StoppableThread):

View File

@ -3,10 +3,10 @@ Create bitmessage protocol command packets
""" """
import struct import struct
import addresses from pybitmessage import addresses
from network.constants import MAX_ADDR_COUNT from constants import MAX_ADDR_COUNT
from network.node import Peer from node import Peer
from protocol import CreatePacket, encodeHost from pybitmessage.protocol import CreatePacket, encodeHost
def assemble_addr(peerList): def assemble_addr(peerList):

View File

@ -17,9 +17,9 @@ from errno import (
ECONNRESET, EHOSTUNREACH, EINPROGRESS, EINTR, EINVAL, EISCONN, ENETUNREACH, ECONNRESET, EHOSTUNREACH, EINPROGRESS, EINTR, EINVAL, EISCONN, ENETUNREACH,
ENOTCONN, ENOTSOCK, EPIPE, ESHUTDOWN, ETIMEDOUT, EWOULDBLOCK, errorcode ENOTCONN, ENOTSOCK, EPIPE, ESHUTDOWN, ETIMEDOUT, EWOULDBLOCK, errorcode
) )
from threading import current_thread from pybitmessage import helper_random
import helper_random from threading import current_thread
try: try:
from errno import WSAEWOULDBLOCK from errno import WSAEWOULDBLOCK

View File

@ -4,11 +4,11 @@ BMObject and it's exceptions.
import logging import logging
import time import time
import protocol from dandelion import Dandelion
import state from pybitmessage import protocol
from addresses import calculateInventoryHash from pybitmessage import state
from inventory import Inventory from pybitmessage.addresses import calculateInventoryHash
from network.dandelion import Dandelion from pybitmessage.inventory import Inventory
logger = logging.getLogger('default') logger = logging.getLogger('default')

View File

@ -10,28 +10,28 @@ import struct
import time import time
from binascii import hexlify from binascii import hexlify
import addresses
import connectionpool import connectionpool
import knownnodes import knownnodes
import protocol from advanceddispatcher import AdvancedDispatcher
import state from bmobject import (
from bmconfigparser import BMConfigParser
from inventory import Inventory
from network.advanceddispatcher import AdvancedDispatcher
from network.bmobject import (
BMObject, BMObjectAlreadyHaveError, BMObjectExpiredError, BMObject, BMObjectAlreadyHaveError, BMObjectExpiredError,
BMObjectInsufficientPOWError, BMObjectInvalidDataError, BMObjectInsufficientPOWError, BMObjectInvalidDataError,
BMObjectInvalidError, BMObjectUnwantedStreamError BMObjectInvalidError, BMObjectUnwantedStreamError
) )
from network.constants import ( from constants import (
ADDRESS_ALIVE, MAX_MESSAGE_SIZE, MAX_OBJECT_COUNT, ADDRESS_ALIVE, MAX_MESSAGE_SIZE, MAX_OBJECT_COUNT,
MAX_OBJECT_PAYLOAD_SIZE, MAX_TIME_OFFSET MAX_OBJECT_PAYLOAD_SIZE, MAX_TIME_OFFSET
) )
from network.dandelion import Dandelion from dandelion import Dandelion
from network.proxy import ProxyError from proxy import ProxyError
from node import Node, Peer from node import Node, Peer
from objectracker import ObjectTracker, missingObjects from objectracker import ObjectTracker, missingObjects
from queues import invQueue, objectProcessorQueue, portCheckerQueue from pybitmessage import addresses
from pybitmessage import protocol
from pybitmessage import state
from pybitmessage.bmconfigparser import BMConfigParser
from pybitmessage.inventory import Inventory
from pybitmessage.queues import invQueue, objectProcessorQueue, portCheckerQueue
from randomtrackingdict import RandomTrackingDict from randomtrackingdict import RandomTrackingDict
logger = logging.getLogger('default') logger = logging.getLogger('default')

View File

@ -6,10 +6,10 @@ import logging
import random # nosec import random # nosec
import knownnodes import knownnodes
import protocol from pybitmessage import protocol
import state from pybitmessage import state
from bmconfigparser import BMConfigParser from pybitmessage.bmconfigparser import BMConfigParser
from queues import Queue, portCheckerQueue from pybitmessage.queues import Queue, portCheckerQueue
logger = logging.getLogger('default') logger = logging.getLogger('default')

View File

@ -9,15 +9,15 @@ import sys
import time import time
import asyncore_pollchoose as asyncore import asyncore_pollchoose as asyncore
import helper_random
import knownnodes import knownnodes
import protocol
import state
from bmconfigparser import BMConfigParser
from connectionchooser import chooseConnection from connectionchooser import chooseConnection
from node import Peer from node import Peer
from proxy import Proxy from proxy import Proxy
from singleton import Singleton from pybitmessage import helper_random
from pybitmessage import protocol
from pybitmessage import state
from pybitmessage.bmconfigparser import BMConfigParser
from pybitmessage.singleton import Singleton
from tcp import ( from tcp import (
bootstrap, Socks4aBMConnection, Socks5BMConnection, bootstrap, Socks4aBMConnection, Socks5BMConnection,
TCPConnection, TCPServer) TCPConnection, TCPServer)

View File

@ -8,9 +8,9 @@ from threading import RLock
from time import time from time import time
import connectionpool import connectionpool
import state from pybitmessage import state
from queues import invQueue from pybitmessage.queues import invQueue
from singleton import Singleton from pybitmessage.singleton import Singleton
# randomise routes after 600 seconds # randomise routes after 600 seconds
REASSIGN_INTERVAL = 600 REASSIGN_INTERVAL = 600

View File

@ -3,13 +3,13 @@
""" """
import time import time
import addresses
import helper_random
import protocol
from dandelion import Dandelion from dandelion import Dandelion
from inventory import Inventory from connectionpool import BMConnectionPool
from network.connectionpool import BMConnectionPool
from objectracker import missingObjects from objectracker import missingObjects
from pybitmessage import addresses
from pybitmessage import helper_random
from pybitmessage import protocol
from pybitmessage.inventory import Inventory
from threads import StoppableThread from threads import StoppableThread

View File

@ -5,12 +5,12 @@ import Queue
import random import random
from time import time from time import time
import addresses from connectionpool import BMConnectionPool
import protocol from dandelion import Dandelion
import state from pybitmessage import addresses
from network.connectionpool import BMConnectionPool from pybitmessage import protocol
from network.dandelion import Dandelion from pybitmessage import state
from queues import invQueue from pybitmessage.queues import invQueue
from threads import StoppableThread from threads import StoppableThread

View File

@ -13,9 +13,9 @@ try:
except ImportError: except ImportError:
from collections import Iterable from collections import Iterable
import state from node import Peer
from bmconfigparser import BMConfigParser from pybitmessage import state
from network.node import Peer from pybitmessage.bmconfigparser import BMConfigParser
state.Peer = Peer state.Peer = Peer

View File

@ -1,10 +1,10 @@
""" """
A thread to handle network concerns A thread to handle network concerns
""" """
import network.asyncore_pollchoose as asyncore import asyncore_pollchoose as asyncore
import state from connectionpool import BMConnectionPool
from network.connectionpool import BMConnectionPool from pybitmessage import state
from queues import excQueue from pybitmessage.queues import excQueue
from threads import StoppableThread from threads import StoppableThread

View File

@ -4,8 +4,8 @@ Module for tracking objects
import time import time
from threading import RLock from threading import RLock
import network.connectionpool import connectionpool
from network.dandelion import Dandelion from dandelion import Dandelion
from randomtrackingdict import RandomTrackingDict from randomtrackingdict import RandomTrackingDict
haveBloom = False haveBloom = False
@ -100,7 +100,7 @@ class ObjectTracker(object):
def handleReceivedObject(self, streamNumber, hashid): def handleReceivedObject(self, streamNumber, hashid):
"""Handling received object""" """Handling received object"""
for i in network.connectionpool.BMConnectionPool().connections(): for i in connectionpool.BMConnectionPool().connections():
if not i.fullyEstablished: if not i.fullyEstablished:
continue continue
try: try:

View File

@ -8,7 +8,7 @@ import time
import asyncore_pollchoose as asyncore import asyncore_pollchoose as asyncore
from advanceddispatcher import AdvancedDispatcher from advanceddispatcher import AdvancedDispatcher
from bmconfigparser import BMConfigParser from pybitmessage.bmconfigparser import BMConfigParser
from node import Peer from node import Peer
logger = logging.getLogger('default') logger = logging.getLogger('default')

View File

@ -4,7 +4,7 @@ Track randomize ordered dict
from threading import RLock from threading import RLock
from time import time from time import time
import helper_random from pybitmessage import helper_random
class RandomTrackingDict(object): class RandomTrackingDict(object):

View File

@ -5,10 +5,10 @@ import errno
import Queue import Queue
import socket import socket
import state from advanceddispatcher import UnknownStateError
from network.advanceddispatcher import UnknownStateError from connectionpool import BMConnectionPool
from network.connectionpool import BMConnectionPool from pybitmessage import state
from queues import receiveDataQueue from pybitmessage.queues import receiveDataQueue
from threads import StoppableThread from threads import StoppableThread

View File

@ -2,35 +2,35 @@
TCP protocol handler TCP protocol handler
""" """
# pylint: disable=too-many-ancestors # pylint: disable=too-many-ancestors
import l10n
import logging import logging
import math import math
import random import random
import socket import socket
import time import time
import addresses
import asyncore_pollchoose as asyncore import asyncore_pollchoose as asyncore
import connectionpool import connectionpool
import helper_random
import knownnodes import knownnodes
import protocol from advanceddispatcher import AdvancedDispatcher
import state from assemble import assemble_addr
from bmconfigparser import BMConfigParser from bmproto import BMProto
from helper_random import randomBytes from constants import MAX_OBJECT_COUNT
from inventory import Inventory from dandelion import Dandelion
from network.advanceddispatcher import AdvancedDispatcher from objectracker import ObjectTracker
from network.assemble import assemble_addr from socks4a import Socks4aConnection
from network.bmproto import BMProto from socks5 import Socks5Connection
from network.constants import MAX_OBJECT_COUNT from tls import TLSDispatcher
from network.dandelion import Dandelion from pybitmessage import addresses
from network.objectracker import ObjectTracker from pybitmessage import helper_random
from network.socks4a import Socks4aConnection from pybitmessage import l10n
from network.socks5 import Socks5Connection from pybitmessage import protocol
from network.tls import TLSDispatcher from pybitmessage import 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 pybitmessage.tr import _translate
from node import Peer from node import Peer
from queues import invQueue, receiveDataQueue, UISignalQueue
from tr import _translate
logger = logging.getLogger('default') logger = logging.getLogger('default')

View File

@ -7,10 +7,10 @@ import socket
import ssl import ssl
import sys import sys
import network.asyncore_pollchoose as asyncore import asyncore_pollchoose as asyncore
import paths from advanceddispatcher import AdvancedDispatcher
from network.advanceddispatcher import AdvancedDispatcher from pybitmessage import paths
from queues import receiveDataQueue from pybitmessage.queues import receiveDataQueue
logger = logging.getLogger('default') logger = logging.getLogger('default')

View File

@ -5,12 +5,12 @@ import logging
import socket import socket
import time import time
import protocol
import state
from bmproto import BMProto from bmproto import BMProto
from node import Peer from node import Peer
from objectracker import ObjectTracker from objectracker import ObjectTracker
from queues import receiveDataQueue from pybitmessage import protocol
from pybitmessage import state
from pybitmessage.queues import receiveDataQueue
logger = logging.getLogger('default') logger = logging.getLogger('default')

View File

@ -3,11 +3,11 @@
""" """
import time import time
import helper_random from connectionpool import BMConnectionPool
import protocol from dandelion import Dandelion
from inventory import Inventory from pybitmessage import helper_random
from network.connectionpool import BMConnectionPool from pybitmessage import protocol
from network.dandelion import Dandelion from pybitmessage.inventory import Inventory
from randomtrackingdict import RandomTrackingDict from randomtrackingdict import RandomTrackingDict
from threads import StoppableThread from threads import StoppableThread

View File

@ -4,11 +4,11 @@ Module for using filesystem (directory with files) for inventory storage
import string import string
import time import time
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from debug import logger
from os import listdir, makedirs, path, remove, rmdir from os import listdir, makedirs, path, remove, rmdir
from threading import RLock from threading import RLock
from paths import lookupAppdataFolder from pybitmessage.debug import logger
from pybitmessage.paths import lookupAppdataFolder
from storage import InventoryItem, InventoryStorage from storage import InventoryItem, InventoryStorage

View File

@ -5,7 +5,7 @@ import sqlite3
import time import time
from threading import RLock from threading import RLock
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery from pybitmessage.helper_sql import SqlBulkExecute, sqlExecute, sqlQuery
from storage import InventoryItem, InventoryStorage from storage import InventoryItem, InventoryStorage

View File

@ -4,12 +4,13 @@ Tests for RandomTrackingDict class
import random import random
import unittest import unittest
from network import randomtrackingdict
from time import time from time import time
class TestRandomTrackingDict(unittest.TestCase): class TestRandomTrackingDict(unittest.TestCase):
"""Main protocol test case""" """
Main protocol test case
"""
@staticmethod @staticmethod
def randString(): def randString():
@ -21,8 +22,12 @@ class TestRandomTrackingDict(unittest.TestCase):
def test_check_randomtrackingdict(self): def test_check_randomtrackingdict(self):
"""Check the logic of RandomTrackingDict class""" """Check the logic of RandomTrackingDict class"""
# from network import RandomTrackingDict
# from pybitmessage.network.randomtrackingdict import RandomTrackingDict
# from network.randomtrackingdict import RandomTrackingDict
from pybitmessage import network
a = [] a = []
k = randomtrackingdict.RandomTrackingDict() k = network.randomtrackingdict.RandomTrackingDict()
a.append(time()) a.append(time())
for i in range(50000): for i in range(50000):