Example #1
0
from utils.protocol import Socket
import config

if getattr(config, 'http_sink', False):
    my_config = {
        'broker': getattr(config, 'broker', '127.0.0.1'),
        'node_name': 'http_sink',
        'port': 8808,
        'sinks': [], 'pollers': [], 'apis': []
    }
    my_config.update(config.http_sink)
    protocolsock = Socket(my_config['node_name'], my_config['broker'], './certificates')

    import tornado.ioloop
    ioloop = tornado.ioloop.IOLoop.current()
    protocolsock.tornado_register(ioloop)

    from .base import Periodic, Api
    import importlib
    import traceback
    import tornado.web

    if  my_config['sinks']:
        print('Configuring for {} sink modules'.format(len(my_config['sinks'])))

        sink_handlers = []

        for sink in my_config['sinks']:
            s = None
            try:
                s = importlib.import_module('nodes.py3_http_sink.sinks.{}'.format(sink))
Example #2
0
# This stack of nested if/else statements would likely be better refactored to use exceptions.
if getattr(config, 'irc', False):
    my_config = {
        'broker': getattr(config, 'broker', '127.0.0.1'),
        'node_name': 'irc',
        'nickname': 'muhubot',
        'servers': []
    }
    my_config.update(config.irc)
    if my_config['servers']:
        print('Configuring for {} servers'.format(len(my_config['servers'])))
        zmq_sock = Socket(my_config['node_name'], my_config['broker'],
                          './certificates')
        import tornado.ioloop
        ioloop = tornado.ioloop.IOLoop.current()
        zmq_sock.tornado_register(ioloop)
        import pydle
        pool = pydle.ClientPool()
        for s in my_config['servers']:
            if 'server' not in s:
                print('Missing "server" config value')
            elif ('channels'
                  not in s) or (type(s['channels']) != list) or (len(
                      s['channels']) == 0):
                print('Invalid "channels" list for {}'.format(s['server']))
            else:
                opts = {
                    'nickname': my_config['nickname'],
                    'port': 6667,
                    'ssl': False,
                    'password': "",
Example #3
0
# This stack of nested if/else statements would likely be better refactored to use exceptions.
if getattr(config, 'irc', False):
    my_config = {
        'broker': getattr(config, 'broker', '127.0.0.1'),
        'node_name': 'irc',
        'nickname': 'muhubot',
        'servers': []
    }
    my_config.update(config.irc)
    if my_config['servers']:
        print('Configuring for {} servers'.format(len(my_config['servers'])))
        zmq_sock = Socket(my_config['node_name'], my_config['broker'], './certificates')
        import tornado.ioloop
        ioloop = tornado.ioloop.IOLoop.current()
        zmq_sock.tornado_register(ioloop)
        import pydle
        pool = pydle.ClientPool()
        for s in my_config['servers']:
            if 'server' not in s:
                print('Missing "server" config value')
            elif ('channels' not in s) or (type(s['channels']) != list) or (len(s['channels']) == 0):
                print('Invalid "channels" list for {}'.format(s['server']))
            else:
                opts = {
                    'nickname': my_config['nickname'], 'port': 6667, 'ssl': False, 'password': "", 'user_map': {}
                }
                opts.update(s)
                from .standard_bot import standard_bot
                server = standard_bot(zmq_sock, **opts)
                servers.append(server)
Example #4
0
if getattr(config, 'http_sink', False):
    my_config = {
        'broker': getattr(config, 'broker', '127.0.0.1'),
        'node_name': 'http_sink',
        'port': 8808,
        'sinks': [],
        'pollers': [],
        'apis': []
    }
    my_config.update(config.http_sink)
    protocolsock = Socket(my_config['node_name'], my_config['broker'],
                          './certificates')

    import tornado.ioloop
    ioloop = tornado.ioloop.IOLoop.current()
    protocolsock.tornado_register(ioloop)

    from .base import Periodic, Api
    import importlib
    import traceback
    import tornado.web

    if my_config['sinks']:
        print('Configuring for {} sink modules'.format(len(
            my_config['sinks'])))

        sink_handlers = []

        for sink in my_config['sinks']:
            s = None
            try: