add Humor Department. fix small printing formatting.

workspace
Brendan Howell 9 years ago
parent 5d1df02ee0
commit 2ac3ba6ecb

@ -111,7 +111,7 @@ class Bureau(object):
# TODO: retry this a few times with a proper sleep/timeout
time.sleep(0.5)
try:
ret = json.loads(sender.recv(flags=zmq.NOBLOCK))
ret = json.loads(sender.recv_string(flags=zmq.NOBLOCK))
# TODO: deal with non-json replies
except zmq.ZMQError:
print("message sent but got no reply...")
@ -173,13 +173,15 @@ class Bureau(object):
subprocess.call("lpr -P " + lpname + " " + pdffile)
def print_small(self, text, printer="/dev/usb/lp1"):
# TODO: make this asynchronous
def print_small(self, text, printer="/dev/usb/lp0"):
"""
print on Thermal Line printer.
"""
# TODO: look this up in config
lp = open(printer, "w")
text += "\r\n" * 10
text += ".d0"
text += "\r\n" * 5
# text += ".d0"
lp.write(text)
lp.close()

@ -21,7 +21,8 @@ class Humor(Bureau):
"""
Prints a clever quip.
"""
print(str.decode(subprocess.check_output("fortune")))
jux = str(subprocess.check_output("fortune"), encoding="UTF-8")
self.print_small(jux)
if __name__ == "__main__":

Loading…
Cancel
Save