Tuesday 2 March 2010

concerto + twitter

During the trials of concerto at CERN, I wanted to make the text fields a bit more dynamic like say following a specific twitter feed.

This would (ideally) simply consist of a DB entry with type=twitter, value=name of person. In the Real World however I got round this by hacking up a simple python script that connects to the DB and does a simple UPDATE of an existing text/plain entry via cron.

posted below incase others find it useful:

#!/usr/bin/python

# Script to pull twitter feeds for cern / lhcstatus
import twitter
import MySQLdb


conn = MySQLdb.connect (host = "...", user = "...", passwd = "...", db = "...")
api = twitter.Api()
feeds = { 'cern': 25, 'lhcstatus': 28 }
for f in feeds:
tweets = api.GetUserTimeline(f,count=1)
for tweet in tweets:
sql = 'UPDATE content SET CONTENT = "%s" WHERE id = %s' % (tweet.GetText(),feeds[f])
cursor = conn.cursor ()
try:
cursor.execute(sql)
conn.commit()
except:
conn.rollback()
cursor.close ()
conn.close ()


yes its hacky, but hey, called from cron regularly it works :-)

2 comments:

Anonymous said...

So... what's your opinion of Concerto. Xalior seemed to suggest that you weren't much of a fan, but it'd be good to hear your pros/cons.

Andrew Elwell said...

OK, The 'corporate' standard here is to use SCALA v5. It costs $$$$, the player needs rebooting daily, and to do anything 'fancy' needs VB script hacks and the designer is dongle protected, needs windows and costs even more $$$$.

So, compared to that, a free system seems wonderful :-)

Good stuff 1) It's a LAMP application - if you can grok PHP you can work out what it does and what the DB is used for. I have a set of cron / curl scripts that overwrite the static images with updates. Works well.

2) Flexible template method (text editor + gimp) - simple to implement the next corporate makeover / dept reshuffle.

3) Managed to rip out n replace the CAS sign-on and use the apache shibboleth stuff to merge with our SSO (scala needed separate user login)

4) support mailing list pretty responsive


Bad stuff -- 1) the dynamic HTML stuff is poorly documented

2) it's a student work in progress - when they feel an urge to migrate to the next 'cool thing' (RoR say...) then the next version will use that.

3) I don't have enough shiny hardware to test it against :-)

Feeling Pumped!

Having just had a day without power, and then going round the site to check everything came back online correctly (including services such a...