blocking = 0
if(pylirc.init("pylirc", "./conf", blocking)):
code = {"config" : ""}
while(code["config"] != "quit"):
# Read next code
s = pylirc.nextcode(1)
# Loop as long as there are more on the queue
# (dont want to wait a second if the user pressed many buttons...)
while(s):
for (code) in s:
#print "Command: %s, Repeat: %d" % (code["config"], code["repeat"])
event = code["config"]
if (event == "test"):
self.publish(server_events, event,hostname)
print (server_events, code["config"], hostname)
if (event == "quit"):
pylirc.exit()
if(not blocking):
s = pylirc.nextcode(1)
else:
s = []
# Clean up lirc
pylirc.exit()