# Path: bitsd/common.py
# LOG = logging.getLogger('tornado.general')


import tornado.tcpserver
from tornado.options import options
from tornado.iostream import StreamClosedError
from bitsd.common import LOG
from .hooks import *
#
# Copyright (C) 2013 Stefano Sanfilippo
# Copyright (C) 2013 BITS development team
#
# This file is part of bitsd, which is released under the terms of
# GNU GPLv3. See COPYING at top level for more information.
#


"""
TCP server receiving raw messages and invoke correct handlers
(from module `.hooks`). Listens for remote commands on BITS-miniprotocol
and dispatches to Fonera via bitsd.client.fonera.Fonera proxy.
"""




def send(string):
    if RemoteListener.STREAM is None:
        LOG.error("No Fonera connected! Not sending %r", string)
        return
    try:
        RemoteListener.STREAM.write(string)
    except StreamClosedError as error:

# Path: bitsd/common.py
# LOG = logging.getLogger('tornado.general')


# Path: bitsd/listener/handlers.py
import tornado.tcpserver
from tornado.options import options
from tornado.iostream import StreamClosedError
from bitsd.common import LOG
from .hooks import *

#
# Copyright (C) 2013 Stefano Sanfilippo
# Copyright (C) 2013 BITS development team
#
# This file is part of bitsd, which is released under the terms of
# GNU GPLv3. See COPYING at top level for more information.
#


"""
TCP server receiving raw messages and invoke correct handlers
(from module `.hooks`). Listens for remote commands on BITS-miniprotocol
and dispatches to Fonera via bitsd.client.fonera.Fonera proxy.
"""




def send(string):
    if RemoteListener.STREAM is None:
        LOG.error("No Fonera connected! Not sending %r", string)
        return
    try:
        RemoteListener.STREAM.write(string)
    except StreamClosedError as error:

        LOG.error('Could not push message to Fonera! %s', error)