You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by rb...@apache.org on 2015/05/29 17:33:00 UTC

svn commit: r1682503 - in /comdev/tools: ./ get_meetups

Author: rbowen
Date: Fri May 29 15:33:00 2015
New Revision: 1682503

URL: http://svn.apache.org/r1682503
Log:
Adds 'get_meetups' tool for help in promoting ASF-related events. PLEASE
read comments in the script before you go blindly using it.

Added:
    comdev/tools/
    comdev/tools/get_meetups   (with props)

Added: comdev/tools/get_meetups
URL: http://svn.apache.org/viewvc/comdev/tools/get_meetups?rev=1682503&view=auto
==============================================================================
--- comdev/tools/get_meetups (added)
+++ comdev/tools/get_meetups Fri May 29 15:33:00 2015
@@ -0,0 +1,155 @@
+#!/usr/bin/python
+import datetime
+from datetime import date
+import urllib2
+import json
+import time
+import re
+
+
+###########################
+#
+# Produces three files containing possible Apache-related meetups. One
+# is formatted to paste onto a mailing list. One is suggested tweets.
+# One is for pasting into a Mediawiki Wiki, and so will need to
+# be modified for use at the ASF.
+#
+# Note that these are POSSIBLY Apache-related. Typically, there's around
+# a 50% false positive rate, what with hiking trails, native American
+# dance enthusiasts, and heilcopter fans. These lists MUST be manually
+# filtered before they are used anywhere publicly.
+#
+# See also note below about the API key.
+#
+# rbowen@apache.org 
+# 29 May 2015
+#
+###########################
+
+# Magic
+import sys    # sys.setdefaultencoding is cancelled by site.py
+reload(sys)    # to re-enable sys.setdefaultencoding()
+sys.setdefaultencoding('utf-8')
+
+print "Rounding up the ponies ..."
+
+# Note that this API key is *my* API key (rbowen) and if we start using
+# it more than a few dozen times an hour it's likely to get revoked.
+# Please play nice.
+key = "3a7711454d145e404e531c2ee6f391d"
+
+# Radius is defined around Lexington, KY, but it's infinite radius, so
+# should work everywhere.
+url = "https://api.meetup.com/2/open_events?&sign=true&photo-host=public&state=ky&city=lexington&country=usa&text=apache&radius=10000&sign=true&key=" + key
+
+# A week for twitter and mailing list ...
+week = 7
+
+# Two weeks for the website
+twoweek = 14
+
+now = datetime.datetime.now()
+nowts  = time.mktime(now.timetuple())
+
+print "Fetching meetups ..."
+
+response = urllib2.urlopen(url)
+m = response.read()
+
+print "Parsing results ..."
+r = json.loads(m)
+meetups = r['results']
+
+groups = {}
+
+print "Fetching group details ..."
+
+for meetup in meetups:
+    groups[ str( meetup['group']['id'] ) ] = meetup['group']['name']
+
+keys = groups.keys()
+keyarg = ",".join( keys )
+
+group_url = "https://api.meetup.com/2/groups?&sign=true&photo-host=public&group_id=" + keyarg + "&key=" + key
+
+response = urllib2.urlopen( group_url )
+m = response.read()
+r = json.loads(m)
+
+grps = r['results']
+
+grp_deets = {}
+for g in grps:
+    grp_deets[ g['id'] ] = g
+
+print "Ok, ready to print meetup details ..."
+
+weeklater = (nowts * 1000 ) + ( week * 86400 * 1000 )
+twoweeklater = (nowts * 1000 ) + ( twoweek * 86400 * 1000 )
+
+tweets = open('meetups.tweets', 'w')
+mlist = open('meetups.mlist', 'w')
+wiki = open('meetups.wiki', 'w')
+
+# Standard intro to mailing list post
+mlist.write( '''The following are the meetups I'm aware of in the coming week where
+Apache enthusiasts are likely to be present. If you know
+of others, please let me know, and/or add them to
+http://apache.org/events
+
+If there's a meetup in your area, please consider attending. If you
+attend, please consider taking a few photos, and possibly even writing
+up a brief summary of what was covered.
+
+--Rich
+
+''')
+
+for meetup in meetups:
+    eventts = int( meetup['time'] + meetup['utc_offset'] )
+
+    # Skip it if it's more than two weeks away
+    if eventts > twoweeklater:
+        continue
+
+    eventtime = date.fromtimestamp( eventts/1000 )
+    t = eventtime.strftime("%c");
+
+    # Don't care about the time
+    t = re.sub( ' \d\d:\d\d:\d\d \d\d\d\d', '', t );
+
+    # Group information ...
+    grp = grp_deets[ meetup['group']['id'] ]
+
+    # For the wiki ...
+    eventout = "* " + t + ' [' + meetup['event_url'] + ' ' + meetup['name'] + "], " + grp['city'] + ', '
+    if 'state' in grp.keys():
+        eventout = eventout + grp['state'] + ', '
+    eventout = eventout + grp['country'] + "\n"
+    wiki.write( str(eventout) )
+
+    # For everything else, a week is enough
+    if eventts > weeklater:
+        continue
+
+    # For Twitter
+    eventout = t + ' in ' + grp['city'] + ', '
+    if 'state' in grp.keys():
+        eventout = eventout + grp['state'] + ', '
+    eventout = eventout + grp['country'] + ': ' + meetup['name'] + ' - ' + meetup['event_url'] + " #Apache #Meetup\n"
+    tweets.write( str( eventout ))
+
+    # For mailing list
+    eventout = '* ' + t + ' in ' + grp['city'] + ', '
+    if 'state' in grp.keys():
+        eventout = eventout + grp['state'] + ', '
+    eventout = eventout + grp['country'] + ': ' + meetup['name'] + ' - ' + meetup['event_url'] + "\n\n"
+    mlist.write( str( eventout ))
+
+# Barn door
+tweets.close()
+mlist.close()
+wiki.close()
+
+print "Done!\n"
+

Propchange: comdev/tools/get_meetups
------------------------------------------------------------------------------
    svn:executable = *