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
def tick(ev): updates = network.read() if len( updates ) == 0: return dlines = data.split( "\n" ) for i in dlines: handle( edicomm.decode( i ) )
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)
def list(network): return network_auth.read(network)
def read(network, query): return network_auth.read(network)
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])
def read(network, relation): return network_auth.read(network)
def read(network, entity): return network_auth.read(network)
def read(network, schema): return network_auth.read(network)