diff --git a/run-autopep8.sh b/run-autopep8.sh deleted file mode 100755 index e879318f..00000000 --- a/run-autopep8.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -autopep8 --in-place --recursive src diff --git a/src/api.py b/src/api.py index be2a64dd..a4445569 100644 --- a/src/api.py +++ b/src/api.py @@ -328,7 +328,6 @@ class testmode(object): # pylint: disable=too-few-public-methods class command(object): # pylint: disable=too-few-public-methods """Decorator for API command method""" - def __init__(self, *aliases): self.aliases = aliases diff --git a/src/backend/address_generator.py b/src/backend/address_generator.py index f5455a42..312c313b 100644 --- a/src/backend/address_generator.py +++ b/src/backend/address_generator.py @@ -12,7 +12,6 @@ from pybitmessage.defaults import ( class AddressGenerator(object): """"Base class for address generation and validation""" - def __init__(self): pass diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 4d8ea61d..f51ee063 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -9,27 +9,6 @@ The PyBitmessage startup script # Right now, PyBitmessage only support connecting to stream 1. It doesn't # yet contain logic to expand into further streams. -from threads import ( - set_thread_name, printLock, - addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread) -from singleinstance import singleinstance -from inventory import Inventory -from helper_startup import ( - adjustHalfOpenConnectionsLimit, fixSocket, start_proxyconfig) -from debug import logger # this should go before any threads -from bmconfigparser import config -from testmode_init import populate_api_test_data -import state -import shutdown -import network -import defaults -import traceback -import time -import threading -import signal -import multiprocessing -import getopt -import depends import os import sys @@ -39,13 +18,34 @@ except ImportError: from pybitmessage import pathmagic app_dir = pathmagic.setup() +import depends depends.check_dependencies() +import getopt +import multiprocessing # Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully. +import signal +import threading +import time +import traceback +import defaults # Network subsystem +import network +import shutdown +import state +from testmode_init import populate_api_test_data +from bmconfigparser import config +from debug import logger # this should go before any threads +from helper_startup import ( + adjustHalfOpenConnectionsLimit, fixSocket, start_proxyconfig) +from inventory import Inventory +from singleinstance import singleinstance # Synchronous threads +from threads import ( + set_thread_name, printLock, + addressGenerator, objectProcessor, singleCleaner, singleWorker, sqlThread) def signal_handler(signum, frame): @@ -81,7 +81,6 @@ def signal_handler(signum, frame): class Main(object): """Main PyBitmessage class""" - def start(self): """Start main application""" # pylint: disable=too-many-statements,too-many-branches,too-many-locals diff --git a/src/bmconfigparser.py b/src/bmconfigparser.py index 1062e630..abf285ad 100644 --- a/src/bmconfigparser.py +++ b/src/bmconfigparser.py @@ -128,7 +128,7 @@ class BMConfigParser(SafeConfigParser): shutil.copyfile(fileName, fileNameBak) # The backup succeeded. fileNameExisted = True - except (IOError, Exception): + except(IOError, Exception): # The backup failed. This can happen if the file # didn't exist before. fileNameExisted = False diff --git a/src/class_objectProcessor.py b/src/class_objectProcessor.py index 394601be..1a71f929 100644 --- a/src/class_objectProcessor.py +++ b/src/class_objectProcessor.py @@ -43,7 +43,6 @@ class objectProcessor(threading.Thread): The objectProcessor thread, of which there is only one, receives network objects (msg, broadcast, pubkey, getpubkey) from the receiveDataThreads. """ - def __init__(self): threading.Thread.__init__(self, name="objectProcessor") random.seed() diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index 8392e8d1..7a41f3c1 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -1080,10 +1080,10 @@ class singleWorker(StoppableThread): " more difficult than you are" " willing to do. {2}" ).format(str(float(requiredAverageProofOfWorkNonceTrialsPerByte) - / defaults.networkDefaultProofOfWorkNonceTrialsPerByte), - str(float(requiredPayloadLengthExtraBytes) - / defaults.networkDefaultPayloadLengthExtraBytes), - l10n.formatTimestamp())))) + / defaults.networkDefaultProofOfWorkNonceTrialsPerByte), + str(float(requiredPayloadLengthExtraBytes) + / defaults.networkDefaultPayloadLengthExtraBytes), + l10n.formatTimestamp())))) continue else: # if we are sending a message to ourselves or a chan.. self.logger.info('Sending a message.') diff --git a/src/class_smtpServer.py b/src/class_smtpServer.py index e925bf3f..44ea7c9c 100644 --- a/src/class_smtpServer.py +++ b/src/class_smtpServer.py @@ -35,7 +35,6 @@ class SmtpServerChannelException(Exception): class smtpServerChannel(smtpd.SMTPChannel): """Asyncore channel for SMTP protocol (server)""" - def smtp_EHLO(self, arg): """Process an EHLO""" if not arg: @@ -74,7 +73,6 @@ class smtpServerChannel(smtpd.SMTPChannel): class smtpServerPyBitmessage(smtpd.SMTPServer): """Asyncore SMTP server class""" - def handle_accept(self): """Accept a connection""" pair = self.accept() @@ -182,7 +180,6 @@ class smtpServerPyBitmessage(smtpd.SMTPServer): class smtpServer(StoppableThread): """SMTP server thread""" - def __init__(self, _=None): super(smtpServer, self).__init__(name="smtpServerThread") self.server = smtpServerPyBitmessage(('127.0.0.1', LISTENPORT), None) diff --git a/src/depends.py b/src/depends.py index 39337776..3f08f4d3 100755 --- a/src/depends.py +++ b/src/depends.py @@ -436,7 +436,7 @@ def check_dependencies(verbose=False, optional=False): if sys.hexversion < 0x3000000: logger.error( 'PyBitmessage requires Python 3 or greater') - # has_all_dependencies = False + #has_all_dependencies = False sys.exit() # FIXME: This needs to be uncommented when more of the code is python3 compatible diff --git a/src/helper_msgcoding.py b/src/helper_msgcoding.py index 9c2652d6..225f352c 100644 --- a/src/helper_msgcoding.py +++ b/src/helper_msgcoding.py @@ -37,14 +37,12 @@ class MsgDecodeException(Exception): class DecompressionSizeException(MsgDecodeException): # pylint: disable=super-init-not-called """Decompression resulted in too much data (attack protection)""" - def __init__(self, size): self.size = size class MsgEncode(object): """Message encoder class""" - def __init__(self, message, encoding=BITMESSAGE_ENCODING_SIMPLE): self.data = None self.encoding = encoding @@ -88,7 +86,6 @@ class MsgEncode(object): class MsgDecode(object): """Message decoder class""" - def __init__(self, encoding, data): self.encoding = encoding if self.encoding == BITMESSAGE_ENCODING_EXTENDED: diff --git a/src/inventory.py b/src/inventory.py index ccdf245d..8356262c 100644 --- a/src/inventory.py +++ b/src/inventory.py @@ -21,7 +21,6 @@ class Inventory: Inventory class which uses storage backends to manage the inventory. """ - def __init__(self): self._moduleName = config.safeGet("inventory", "storage") self._realInventory = create_inventory_instance(self._moduleName) diff --git a/src/messagetypes/message.py b/src/messagetypes/message.py index 5989d41c..245c753f 100644 --- a/src/messagetypes/message.py +++ b/src/messagetypes/message.py @@ -5,7 +5,6 @@ logger = logging.getLogger('default') class MsgBase(object): # pylint: disable=too-few-public-methods """Base class for message types""" - def __init__(self): self.data = {"": type(self).__name__.lower()} diff --git a/src/network/__init__.py b/src/network/__init__.py index cc7bfb58..1851e072 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 network.connectionpool as connectionpool # pylint: disable=relative-import + import network.connectionpool as connectionpool # pylint: disable=relative-import from .addrthread import AddrThread from .dandelion import Dandelion from .downloadthread import DownloadThread diff --git a/src/network/asyncore_pollchoose.py b/src/network/asyncore_pollchoose.py index c8b9e364..ccbe2aef 100644 --- a/src/network/asyncore_pollchoose.py +++ b/src/network/asyncore_pollchoose.py @@ -564,12 +564,12 @@ class dispatcher(object): try: kqueue_poller.pollster.control([select.kevent( fd, select.KQ_FILTER_READ, select.KQ_EV_DELETE)], 0) - except (AttributeError, KeyError, TypeError, IOError, OSError): + except(AttributeError, KeyError, TypeError, IOError, OSError): pass try: kqueue_poller.pollster.control([select.kevent( fd, select.KQ_FILTER_WRITE, select.KQ_EV_DELETE)], 0) - except (AttributeError, KeyError, TypeError, IOError, OSError): + except(AttributeError, KeyError, TypeError, IOError, OSError): pass try: epoll_poller.pollster.unregister(fd) @@ -726,7 +726,7 @@ class dispatcher(object): # XXX unresolved # cheap inheritance, used to pass all other attribute # references to the underlying socket object. - # def __getattr__(self, attr): + #def __getattr__(self, attr): # try: # retattr = getattr(self.socket, attr) # except AttributeError: diff --git a/src/network/dandelion.py b/src/network/dandelion.py index 43f36857..846b03e1 100644 --- a/src/network/dandelion.py +++ b/src/network/dandelion.py @@ -28,7 +28,6 @@ logger = logging.getLogger('default') class Dandelion: # pylint: disable=old-style-class """Dandelion class for tracking stem/fluff stages.""" - def __init__(self): # currently assignable child stems self.stem = [] diff --git a/src/network/httpd.py b/src/network/httpd.py index a53d740c..654566c2 100644 --- a/src/network/httpd.py +++ b/src/network/httpd.py @@ -69,7 +69,6 @@ class HTTPRequestHandler(asyncore.dispatcher): class HTTPSRequestHandler(HTTPRequestHandler, TLSHandshake): """Handling HTTPS request""" - def __init__(self, sock): if not hasattr(self, '_map'): asyncore.dispatcher.__init__(self, sock) # pylint: disable=non-parent-init-called diff --git a/src/network/objectracker.py b/src/network/objectracker.py index 0c3c752b..63425def 100644 --- a/src/network/objectracker.py +++ b/src/network/objectracker.py @@ -102,7 +102,7 @@ class ObjectTracker(object): def handleReceivedObject(self, streamNumber, hashid): """Handling received object""" - hashid_bytes = bytes(hashid) + hashid_bytes = bytes(hashid); for i in connectionpool.pool.connections(): if not i.fullyEstablished: continue diff --git a/src/network/receivequeuethread.py b/src/network/receivequeuethread.py index 3dafc15c..68ad6124 100644 --- a/src/network/receivequeuethread.py +++ b/src/network/receivequeuethread.py @@ -15,7 +15,6 @@ from .threads import StoppableThread class ReceiveQueueThread(StoppableThread): """This thread processes data received from the network (which is done by the asyncore thread)""" - def __init__(self, num=0): super(ReceiveQueueThread, self).__init__(name="ReceiveQueue_%i" % num) diff --git a/src/network/socks4a.py b/src/network/socks4a.py index 0b16ded2..2758838a 100644 --- a/src/network/socks4a.py +++ b/src/network/socks4a.py @@ -26,7 +26,6 @@ class Socks4aError(ProxyError): class Socks4a(Proxy): """SOCKS4a proxy class""" - def __init__(self, address=None): Proxy.__init__(self, address) self.ipaddr = None @@ -74,7 +73,6 @@ class Socks4a(Proxy): class Socks4aConnection(Socks4a): """Child SOCKS4a class used for making outbound connections.""" - def __init__(self, address): Socks4a.__init__(self, address=address) @@ -121,7 +119,6 @@ class Socks4aConnection(Socks4a): class Socks4aResolver(Socks4a): """DNS resolver class using SOCKS4a""" - def __init__(self, host): self.host = host self.port = 8444 diff --git a/src/network/socks5.py b/src/network/socks5.py index 3542efc4..1838a737 100644 --- a/src/network/socks5.py +++ b/src/network/socks5.py @@ -42,7 +42,6 @@ class Socks5Error(ProxyError): class Socks5(Proxy): """A socks5 proxy base class""" - def __init__(self, address=None): Proxy.__init__(self, address) self.ipaddr = None @@ -164,7 +163,6 @@ class Socks5(Proxy): class Socks5Connection(Socks5): """Child socks5 class used for making outbound connections.""" - def state_auth_done(self): """Request connection to be made""" # Now we can request the actual connection @@ -201,7 +199,6 @@ class Socks5Connection(Socks5): class Socks5Resolver(Socks5): """DNS resolver class using socks5""" - def __init__(self, host): self.host = host self.port = 8444 diff --git a/src/network/tls.py b/src/network/tls.py index 09841082..2f30fcc0 100644 --- a/src/network/tls.py +++ b/src/network/tls.py @@ -40,12 +40,10 @@ if ( else: sslProtocolCiphers = "AECDH-AES256-SHA" - class TLSDispatcher(AdvancedDispatcher): """TLS functionality for classes derived from AdvancedDispatcher""" # pylint: disable=too-many-instance-attributes, too-many-arguments # pylint: disable=super-init-not-called - def __init__(self, _=None, sock=None, certfile=None, keyfile=None, server_side=False, ciphers=sslProtocolCiphers): self.want_read = self.want_write = True diff --git a/src/pyelliptic/cipher.py b/src/pyelliptic/cipher.py index dedba3a9..2c2c54da 100644 --- a/src/pyelliptic/cipher.py +++ b/src/pyelliptic/cipher.py @@ -22,7 +22,6 @@ class Cipher(object): ctx2 = pyelliptic.Cipher("secretkey", iv, 0, ciphername='aes-256-cfb') print ctx2.ciphering(ciphertext) """ - def __init__(self, key, iv, do, ciphername='aes-256-cbc'): """ do == 1 => Encrypt; do == 0 => Decrypt diff --git a/src/pyelliptic/openssl.py b/src/pyelliptic/openssl.py index aadb3e7e..deb81644 100644 --- a/src/pyelliptic/openssl.py +++ b/src/pyelliptic/openssl.py @@ -100,7 +100,6 @@ class _OpenSSL(object): Wrapper for OpenSSL using ctypes """ # pylint: disable=too-many-statements, too-many-instance-attributes - def __init__(self, library): """ Build the wrapper diff --git a/src/qidenticon.py b/src/qidenticon.py index 92d0b64d..158a2232 100644 --- a/src/qidenticon.py +++ b/src/qidenticon.py @@ -43,7 +43,6 @@ Returns an instance of :class:`QPixmap` which have generated identicon image. from six.moves import range from PyQt6 import QtCore, QtGui - class IdenticonRendererBase(object): """Encapsulate methods around rendering identicons""" diff --git a/src/singleinstance.py b/src/singleinstance.py index 80eb411b..cff9d794 100644 --- a/src/singleinstance.py +++ b/src/singleinstance.py @@ -21,7 +21,6 @@ class singleinstance(object): Implements a single instance application by creating a lock file at appdata. """ - def __init__(self, flavor_id="", daemon=False): self.initialized = False self.counter = 0 diff --git a/src/storage/sqlite.py b/src/storage/sqlite.py index 38d9fd95..6f810a16 100644 --- a/src/storage/sqlite.py +++ b/src/storage/sqlite.py @@ -11,7 +11,6 @@ from .storage import InventoryItem, InventoryStorage class SqliteInventory(InventoryStorage): """Inventory using SQLite""" - def __init__(self): super(SqliteInventory, self).__init__() # of objects (like msg payloads and pubkey payloads) diff --git a/src/tr.py b/src/tr.py index f26dcdff..06e2e5d8 100644 --- a/src/tr.py +++ b/src/tr.py @@ -15,7 +15,6 @@ class translateClass: when we are in daemon mode and not using any QT functions. """ # pylint: disable=old-style-class,too-few-public-methods - def __init__(self, context, text): self.context = context self.text = text