add mailroom PR departments
parent
d1f283e09f
commit
b75211f42f
@ -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/
|
@ -0,0 +1 @@
|
|||||||
|
from bureau import Bureau
|
@ -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()
|
@ -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()
|
Loading…
Reference in New Issue