From b75211f42f5b483a7d55b47b727e35961b361568 Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Sat, 30 May 2015 00:06:46 +0200 Subject: [PATCH] add mailroom PR departments --- .gitignore | 58 ++++++++++++++++++++++++++++ screenless/bureau/__init__.py | 1 + screenless/bureau/evdevkb.py | 0 screenless/bureau/mailroom.py | 50 ++++++++++++++++++++++++ screenless/bureau/publicrelations.py | 50 ++++++++++++++++++++++++ 5 files changed, 159 insertions(+) create mode 100644 .gitignore create mode 100644 screenless/bureau/__init__.py create mode 100644 screenless/bureau/evdevkb.py create mode 100644 screenless/bureau/mailroom.py create mode 100644 screenless/bureau/publicrelations.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a65d046 --- /dev/null +++ b/.gitignore @@ -0,0 +1,58 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ diff --git a/screenless/bureau/__init__.py b/screenless/bureau/__init__.py new file mode 100644 index 0000000..5d21496 --- /dev/null +++ b/screenless/bureau/__init__.py @@ -0,0 +1 @@ +from bureau import Bureau diff --git a/screenless/bureau/evdevkb.py b/screenless/bureau/evdevkb.py new file mode 100644 index 0000000..e69de29 diff --git a/screenless/bureau/mailroom.py b/screenless/bureau/mailroom.py new file mode 100644 index 0000000..fd07a3d --- /dev/null +++ b/screenless/bureau/mailroom.py @@ -0,0 +1,50 @@ +import twitter + +from bureau import Bureau, add_command, add_api + + +class MailRoom(Bureau): + """ + The Mail Room handles (electronic) post for the other Bureaus of + the Screenless Office. + """ + + name = "Mail Room" + prefix = "PS" + version = 0 + + def __init__(self): + Bureau.__init__(self) + + @add_command("fax", "Send a Document Camera Image via Email") + def fax(self, to_id): + """ + Takes a photograph using the document camera and sends it in an E-mail. + """ + callback = self.prefix + "fax." + args = {"to_id": to_id} + self.send("PXphoto.", {"callback": callback, "cb_args": args}) + + @add_api("tweetpic_cb", "callback for tweet_pic") + def tweetpic_cb(self, data): + """ + This does the actual uploading of the picture. + """ + photo = data["photo"] + auth = twitter.OAuth( + "423391766-bhjHwzD1eJfxB9s7ZvmeHReNVJM0d93kJ8KSrHEZ", + "qSvSYMs4lpSKbZtiuOjB1Gon5rzye8whvadcOdDpFocwa", + "arI4UCnfMeKZwAnyvJJIHVnUN", + "agrtzvh3eqSNlZpmPJZ0otclqSUjLKI3JrqugCPrp1Ch9dqsTl") + t = twitter.Twitter(auth=auth) + + with open(photo, "rb") as imagefile: + imagedata = imagefile.read() + t_up = twitter.Twitter(domain='upload.twitter.com', auth=auth) + id_img1 = str(t_up.media.upload(media=imagedata)["media_id"]) + t.statuses.update(status="PTT ★", media_ids=id_img1) + + +if __name__ == "__main__": + pr = PublicRelations() + pr.run() diff --git a/screenless/bureau/publicrelations.py b/screenless/bureau/publicrelations.py new file mode 100644 index 0000000..d84d9e6 --- /dev/null +++ b/screenless/bureau/publicrelations.py @@ -0,0 +1,50 @@ +import twitter + +from bureau import Bureau, add_command, add_api + + +class PublicRelations(Bureau): + """ + The Public relations department manages the flow of information between + the screenless office and the general public. It provides interfaces + for Twitter, Facebook and other electronic PR platforms. + """ + + name = "Public Relations" + prefix = "PR" + version = 0 + + def __init__(self): + Bureau.__init__(self) + + @add_command("tweetpic", "Post a Document Camera Image to Twitter") + def tweet_pic(self): + """ + Takes a photograph using the document camera and posts it to Twitter. + """ + callback = self.prefix + "tweetpic_cb." + self.send("PXphoto.", {"callback": callback}) + + @add_api("tweetpic_cb", "callback for tweet_pic") + def tweetpic_cb(self, data): + """ + This does the actual uploading of the picture. + """ + photo = data["photo"] + auth = twitter.OAuth( + "423391766-bhjHwzD1eJfxB9s7ZvmeHReNVJM0d93kJ8KSrHEZ", + "qSvSYMs4lpSKbZtiuOjB1Gon5rzye8whvadcOdDpFocwa", + "arI4UCnfMeKZwAnyvJJIHVnUN", + "agrtzvh3eqSNlZpmPJZ0otclqSUjLKI3JrqugCPrp1Ch9dqsTl") + t = twitter.Twitter(auth=auth) + + with open(photo, "rb") as imagefile: + imagedata = imagefile.read() + t_up = twitter.Twitter(domain='upload.twitter.com', auth=auth) + id_img1 = str(t_up.media.upload(media=imagedata)["media_id"]) + t.statuses.update(status="PTT ★", media_ids=id_img1) + + +if __name__ == "__main__": + pr = PublicRelations() + pr.run()