def find_location(name): for path in config.get('drivers', []): p = Path(path) / (name + '.py') if p.exists() and p.is_file(): return p p = Path(path) / name if p.exists() and p.is_dir(): return p return None
""" import asyncio import errno import logging import pickle import random import sys from qulab._config import config from qulab.dht.crawling import NodeSpiderCrawl, ValueSpiderCrawl from qulab.dht.node import Node from qulab.dht.protocol import KademliaProtocol from qulab.dht.storage import ForgetfulStorage from qulab.dht.utils import digest cfg = config.get('dht', dict()) DEFALT_PORT = cfg.get('default_port', 8987) log = logging.getLogger(__name__) # pylint: disable=invalid-name # pylint: disable=too-many-instance-attributes class Server: """ High level view of a node instance. This is the object that should be created to start listening as an active node on the network. """ protocol_class = KademliaProtocol def __init__(self, ksize=20, alpha=3, node_id=None, storage=None):
""" import asyncio import errno import logging import pickle import random import sys from qulab._config import config from qulab.dht.crawling import NodeSpiderCrawl, ValueSpiderCrawl from qulab.dht.node import Node from qulab.dht.protocol import KademliaProtocol from qulab.dht.utils import digest from qulab.storage.memstorage import ForgetfulStorage cfg = config.get('dht', dict()) DEFALT_PORT = cfg.get('default_port', 8987) log = logging.getLogger(__name__) # pylint: disable=invalid-name # pylint: disable=too-many-instance-attributes class Server: """ High level view of a node instance. This is the object that should be created to start listening as an active node on the network. """ protocol_class = KademliaProtocol def __init__(self, ksize=20, alpha=3, node_id=None, storage=None):
import logging import zmq from qulab._config import config from qulab.serialize import pack, unpack from qulab.utils import getHostIP cfg = config.get('log', dict()) def level(): """ Get default log level """ return { 'notset': logging.NOTSET, 'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL }[cfg.get('level', 'info')] # yapf: disable class BaseHandler(logging.Handler): """ BaseHandler """ def __init__(self): super().__init__()
import logging import zmq from qulab._config import config from qulab.serialize import pack, unpack from qulab.utils import getHostIP cfg = config.get('log', dict()) def level(): """ Get default log level """ return { 'notset': logging.NOTSET, 'debug': logging.DEBUG, 'info': logging.INFO, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL }[cfg.get('level', 'info')] # yapf: disable class BaseHandler(logging.Handler): """ BaseHandler """ def __init__(self): super().__init__() self.host = getHostIP()