Exemplo n.º 1
0
def get_message(sock, settings, state):

    """
    Read a message from the IRC connection, simulaneously making sure
    to keep the connection alive and handling the IRC statey business.
    Returns the message, perhaps with convenience information attached.

    """

    raw_message = network.read(sock)

    if raw_message:
        message = from_raw(raw_message)
        response = manage(message, settings, state)
        if response:
            send_message(sock, response)
        elif message.command == 'PRIVMSG':
            return message

        return None

    if settings.channel != state.joined:
        if state.joined:
            send_message(sock, Message.part(state.joined))
        send_message(sock, Message.join(settings.channel))
        return None
Exemplo n.º 2
0
def tick(ev):
	updates = network.read()
	if len( updates ) == 0:
		return

	dlines = data.split( "\n" )
	for i in dlines:
		handle( edicomm.decode( i ) )
Exemplo n.º 3
0
import network
import objects
import settings
import parser


socket = network.get(settings.MAX_CUBE_IP, settings.MAX_CUBE_PORT)

message = network.read(socket)

data = parser.parse(message)

header = data['H']
meta = data['M']
devices = data['L']

cube = objects.Cube(
    address=header['address'],
    serial=header['serial'],
    firmware_version=header['firmware_version']
)

for room in meta['rooms'].values():
    cube.add_room(objects.Room(**room))

for device in meta['devices']:
    device_class = objects.Device.get_device_type(device['type'])
    device = device_class(**device)

    cube.add_device(device)
Exemplo n.º 4
0
def list(network):
    return network_auth.read(network)
Exemplo n.º 5
0
def read(network, query):
    return network_auth.read(network)
Exemplo n.º 6
0
import network
import objects
import settings
import parser

socket = network.get(settings.MAX_CUBE_IP, settings.MAX_CUBE_PORT)

message = network.read(socket)

data = parser.parse(message)

header = data['H']
meta = data['M']
devices = data['L']

cube = objects.Cube(address=header['address'],
                    serial=header['serial'],
                    firmware_version=header['firmware_version'])

for room in meta['rooms'].values():
    cube.add_room(objects.Room(**room))

for device in meta['devices']:
    device_class = objects.Device.get_device_type(device['type'])
    device = device_class(**device)

    cube.add_device(device)

    if device.address in devices:
        device.__dict__.update(devices[device.address])
Exemplo n.º 7
0
def read(network, relation):
    return network_auth.read(network)
Exemplo n.º 8
0
def read(network, entity):
    return network_auth.read(network)
Exemplo n.º 9
0
def read(network, schema):
    return network_auth.read(network)