示例#1
0
class DisplayModule:
    def __init__(self,outputer):
        self.outputer=outputer
        self.lines=[]
    def update(self,lines):
        newlist=self.lines+lines
        self.lines=newlist[-4:]
    def output(self):
        self.outputer.clear()
        for line in self.lines:
            self.outputer.println(line)
    def recv(self,queue):
        data=queue.recv_json()
        self.update([data['message']])
        self.output()
    def listen(self,queue):
        while True:
            self.recv(queue)
            
if __name__ == '__main__':
    import zmq, lcdoutputer, yaml
    from limumaatti import Config
    context = zmq.Context()
    yaml = yaml.load(file("limumaatti.yaml").read())
    config = Config(context,yaml)
    queue = config.getSocket("display",1)
    display = DisplayModule(lcdoutputer.lcdoutputer())
    display.listen(queue)
示例#2
0
#!/usr/bin/env python
import socket, zmq, yaml
from limumaatti import Config

hostname="limumaatti.local"

ctx=zmq.Context()
yaml=yaml.load(file("limumaatti.yaml").read())

cfg=Config(ctx,yaml)
msq=cfg.getSocket("display")

msq.send_json({"message":" ".join([hostname,socket.gethostbyname(hostname)])})