run autopep8 on src
This commit is contained in:
parent
1b3ce71f19
commit
24b83aae2a
2
run-autopep8.sh
Executable file
2
run-autopep8.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
autopep8 --in-place --recursive src
|
|
@ -328,6 +328,7 @@ 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
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ from pybitmessage.defaults import (
|
|||
|
||||
class AddressGenerator(object):
|
||||
""""Base class for address generation and validation"""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -9,6 +9,27 @@ 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
|
||||
|
||||
|
@ -18,34 +39,13 @@ 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,6 +81,7 @@ 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
|
||||
|
|
|
@ -43,6 +43,7 @@ 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()
|
||||
|
|
|
@ -35,6 +35,7 @@ class SmtpServerChannelException(Exception):
|
|||
|
||||
class smtpServerChannel(smtpd.SMTPChannel):
|
||||
"""Asyncore channel for SMTP protocol (server)"""
|
||||
|
||||
def smtp_EHLO(self, arg):
|
||||
"""Process an EHLO"""
|
||||
if not arg:
|
||||
|
@ -73,6 +74,7 @@ class smtpServerChannel(smtpd.SMTPChannel):
|
|||
|
||||
class smtpServerPyBitmessage(smtpd.SMTPServer):
|
||||
"""Asyncore SMTP server class"""
|
||||
|
||||
def handle_accept(self):
|
||||
"""Accept a connection"""
|
||||
pair = self.accept()
|
||||
|
@ -180,6 +182,7 @@ 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)
|
||||
|
|
|
@ -37,12 +37,14 @@ 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
|
||||
|
@ -86,6 +88,7 @@ class MsgEncode(object):
|
|||
|
||||
class MsgDecode(object):
|
||||
"""Message decoder class"""
|
||||
|
||||
def __init__(self, encoding, data):
|
||||
self.encoding = encoding
|
||||
if self.encoding == BITMESSAGE_ENCODING_EXTENDED:
|
||||
|
|
|
@ -21,6 +21,7 @@ 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)
|
||||
|
|
|
@ -5,6 +5,7 @@ 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()}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ 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 = []
|
||||
|
|
|
@ -69,6 +69,7 @@ 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -15,6 +15,7 @@ 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)
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ class Socks4aError(ProxyError):
|
|||
|
||||
class Socks4a(Proxy):
|
||||
"""SOCKS4a proxy class"""
|
||||
|
||||
def __init__(self, address=None):
|
||||
Proxy.__init__(self, address)
|
||||
self.ipaddr = None
|
||||
|
@ -73,6 +74,7 @@ class Socks4a(Proxy):
|
|||
|
||||
class Socks4aConnection(Socks4a):
|
||||
"""Child SOCKS4a class used for making outbound connections."""
|
||||
|
||||
def __init__(self, address):
|
||||
Socks4a.__init__(self, address=address)
|
||||
|
||||
|
@ -119,6 +121,7 @@ class Socks4aConnection(Socks4a):
|
|||
|
||||
class Socks4aResolver(Socks4a):
|
||||
"""DNS resolver class using SOCKS4a"""
|
||||
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
self.port = 8444
|
||||
|
|
|
@ -42,6 +42,7 @@ class Socks5Error(ProxyError):
|
|||
|
||||
class Socks5(Proxy):
|
||||
"""A socks5 proxy base class"""
|
||||
|
||||
def __init__(self, address=None):
|
||||
Proxy.__init__(self, address)
|
||||
self.ipaddr = None
|
||||
|
@ -163,6 +164,7 @@ 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
|
||||
|
@ -199,6 +201,7 @@ class Socks5Connection(Socks5):
|
|||
|
||||
class Socks5Resolver(Socks5):
|
||||
"""DNS resolver class using socks5"""
|
||||
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
self.port = 8444
|
||||
|
|
|
@ -40,10 +40,12 @@ 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
|
||||
|
|
|
@ -22,6 +22,7 @@ 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
|
||||
|
|
|
@ -100,6 +100,7 @@ class _OpenSSL(object):
|
|||
Wrapper for OpenSSL using ctypes
|
||||
"""
|
||||
# pylint: disable=too-many-statements, too-many-instance-attributes
|
||||
|
||||
def __init__(self, library):
|
||||
"""
|
||||
Build the wrapper
|
||||
|
|
|
@ -43,6 +43,7 @@ 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"""
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ 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
|
||||
|
|
|
@ -11,6 +11,7 @@ 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)
|
||||
|
|
Reference in New Issue
Block a user