Created
March 29, 2011 13:38
-
-
Save jsoa/892370 to your computer and use it in GitHub Desktop.
Fabric script used to push updates to an activity topic on convore.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update(): | |
""" | |
Cause the site to pull in the latest changes to its code and touch the | |
wsgi file so it reloads | |
""" | |
global site_path | |
with cd(site_path): | |
extra_msg = run('git pull --all') | |
reload() | |
send_convore_update(msg="Push Live", extra=extra_msg) | |
def reload(): | |
""" | |
Reload the apache process by touching the wsgi file | |
""" | |
global site_path, wsgi_path | |
with cd(site_path): | |
run('touch %s' % wsgi_path) | |
CONVORE_CREATE_MESSAGE_URL = "https://convore.com/api/topics/%s/messages/create.json" | |
ACTIVITY_TOPIC_ID = '<TOPIC ID HERE>' | |
@runs_once | |
def send_convore_update(msg, extra=""): | |
""" | |
Send update message to activity topic on convore.com | |
""" | |
try: | |
import urllib, urllib2, base64 | |
url = CONVORE_CREATE_MESSAGE_URL % ACTIVITY_TOPIC_ID | |
username = '<username>' | |
password = '<password>' | |
msg = "%s \n %s" % (msg, extra) | |
values = {'message': msg} | |
data = urllib.urlencode(values) | |
req = urllib2.Request(url, data) | |
base64string = base64.encodestring( | |
'%s:%s' % (username, password))[:-1] | |
authheader = "Basic %s" % base64string | |
req.add_header("Authorization", authheader) | |
handle = urllib2.urlopen(req) | |
except Exception, e: | |
print e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment