From d1f283e09f93c82a5d00dddcb5c4a6e39b5c8b0b Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Tue, 19 May 2015 00:47:36 +0200 Subject: [PATCH] basic document camera module --- screenless/bureau/photography.py | 42 ++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 screenless/bureau/photography.py diff --git a/screenless/bureau/photography.py b/screenless/bureau/photography.py new file mode 100644 index 0000000..e443320 --- /dev/null +++ b/screenless/bureau/photography.py @@ -0,0 +1,42 @@ +import subprocess +import tempfile + +from bureau import Bureau, add_api + + +class Photography(Bureau): + """ + The Photography dept. provides document camera and other image + capture services for the Office. + """ + + name = "Photography Dept." + prefix = "PX" + version = 0 + + def __init__(self): + Bureau.__init__(self) + + @add_api("photo", "Get Document Photo") + def print_fortune(self, data): + """ + Takes a photograph using the document camera. Returns + the file name. + """ + try: + cb = data["callback"] + except KeyError as e: + print(e) + # TODO: this should log a real error + return + tmpimg = tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) + tmpimg.close() + cmd = "fswebcam --jpeg 95 --no-banner --resolution 1920x1080 -D 0.5 " + cmd += "-F 2 " + tmpimg.name + subprocess.check_output(cmd.split()) + self.send(cb, {"photo": tmpimg.name}) + + +if __name__ == "__main__": + px = Photography() + px.run()