community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgard...@apache.org
Subject svn commit: r1683048 - in /comdev/tools/events_list: Dockerfile get_meetups meetups.py menu readme.md
Date Tue, 02 Jun 2015 06:13:31 GMT
Author: rgardler
Date: Tue Jun  2 06:13:31 2015
New Revision: 1683048

URL: http://svn.apache.org/r1683048
Log:
Make the core functionality a module (does not change how the application is used). Provide
an ncurses menu system. Write data to JSON files. This is a precursor to providing a Django
webapp which will allow for persistence and editing of the data.

Added:
    comdev/tools/events_list/meetups.py
    comdev/tools/events_list/menu
Modified:
    comdev/tools/events_list/Dockerfile
    comdev/tools/events_list/get_meetups
    comdev/tools/events_list/readme.md

Modified: comdev/tools/events_list/Dockerfile
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/Dockerfile?rev=1683048&r1=1683047&r2=1683048&view=diff
==============================================================================
--- comdev/tools/events_list/Dockerfile (original)
+++ comdev/tools/events_list/Dockerfile Tue Jun  2 06:13:31 2015
@@ -3,4 +3,4 @@ FROM python:2.7
 COPY . /project
 WORKDIR /project
 
-CMD ["python", "./get_meetups"]
\ No newline at end of file
+CMD ["python", "./get_meetuplist"]
\ No newline at end of file

Modified: comdev/tools/events_list/get_meetups
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/get_meetups?rev=1683048&r1=1683047&r2=1683048&view=diff
==============================================================================
--- comdev/tools/events_list/get_meetups (original)
+++ comdev/tools/events_list/get_meetups Tue Jun  2 06:13:31 2015
@@ -1,154 +1,6 @@
-#!/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 apache.org/events/meetups.mdtext
-#
-# 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')
-website = open('meetups.mdtext', '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 website ...
-    eventout = "* " + t + ' [' + meetup['name'] + '](' + meetup['event_url'] + "), " + grp['city']
+ ', '
-    if 'state' in grp.keys():
-        eventout = eventout + grp['state'] + ', '
-    eventout = eventout + grp['country'] + "\n"
-    website.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()
-website.close()
-
-print "Done!\n"
-
+#!/usr/bin/python
+import curses
+import meetups
+
+meetups.importMeetups()
+meetups.createFiles()
\ No newline at end of file

Added: comdev/tools/events_list/meetups.py
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/meetups.py?rev=1683048&view=auto
==============================================================================
--- comdev/tools/events_list/meetups.py (added)
+++ comdev/tools/events_list/meetups.py Tue Jun  2 06:13:31 2015
@@ -0,0 +1,173 @@
+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 apache.org/events/meetups.mdtext
+#
+# 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')
+
+def importMeetups():
+
+    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
+
+    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']
+
+    print "Writing raw JSON data to 'meetups.json' and 'groups.json'"
+
+    raw = open('meetups.json', 'w')
+    raw.write(json.dumps(meetups, indent=4))
+    raw.close()
+
+    raw = open('groups.json', 'w')
+    raw.write(json.dumps(grps, indent=4))
+    raw.close();
+
+def createFiles():
+    print "Loading meetups database..."
+    
+    # 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())
+
+    with open('meetups.json') as data_file:    
+        meetups = json.load(data_file)
+
+    with open('groups.json') as data_file:    
+        grps = json.load(data_file)
+
+    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')
+    website = open('meetups.mdtext', '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 website ...
+        eventout = "* " + t + ' [' + meetup['name'] + '](' + meetup['event_url'] + "), "
+ grp['city'] + ', '
+        if 'state' in grp.keys():
+            eventout = eventout + grp['state'] + ', '
+        eventout = eventout + grp['country'] + "\n"
+        website.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()
+    website.close()
+
+    print "Done! Check out meetups.mlist, meetups.tweet and meetups.mdtext\n"
+

Added: comdev/tools/events_list/menu
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/menu?rev=1683048&view=auto
==============================================================================
--- comdev/tools/events_list/menu (added)
+++ comdev/tools/events_list/menu Tue Jun  2 06:13:31 2015
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+import curses
+import meetups
+
+def printMenu():
+    scr.addstr("Event List Manager\n")
+    scr.addstr("==================\n\n")
+    scr.addstr("Select a command from the follwing list:\n")
+
+    scr.addstr("i - Import Meetups\n")
+    scr.addstr("l - List Meetups in files\n")
+    scr.addstr("E - Exit\n")
+    scr.addstr("\n");
+
+
+scr = curses.initscr()
+curses.noecho()
+curses.cbreak()
+scr.keypad(1)
+printMenu();
+
+exiting = False;
+while not exiting:
+    c = scr.getch()
+    if c == ord('E'):
+        break
+    elif c == ord('i'):
+        meetups.importMeetups()
+        scr.addstr("\n\n");
+        printMenu()
+    elif c == ord('l'):
+        meetups.createFiles()
+        scr.addstr("\n\n");
+        printMenu()
+        
+curses.nocbreak()
+scr.keypad(0)
+curses.echo()
+curses.endwin()

Modified: comdev/tools/events_list/readme.md
URL: http://svn.apache.org/viewvc/comdev/tools/events_list/readme.md?rev=1683048&r1=1683047&r2=1683048&view=diff
==============================================================================
--- comdev/tools/events_list/readme.md (original)
+++ comdev/tools/events_list/readme.md Tue Jun  2 06:13:31 2015
@@ -1,10 +1,42 @@
 This directory contains tools that are useful for creating and
 managing a list of events related to the ASF.
 
+# Features #
+
+  * Run as a script (get_meetups) or as an interactive menu
+  * Import events from meetups.com that might be Apache related
+  * Generate a mail template for events in the next 7 days
+  * Generate a Markdown file for hosting on a website or similar
+  * Generate a file containing suggested tweets
+
+Run as either a Python application or as a Docker containerized
+application.
+
+# Python Script #
+
+To run the application as a Python script simply execyte get_meetups.
+This will create a number of files in the project directory:
+
+  * meetups.mlist - a template email for events in the next week
+  * meetups.mdtext - a markdown file of events i nthe next 2 weeks
+  * meetups.tweets - suggested tweets for events in the next 2 weeks
+  * meetups.json - a json file of all meetups
+  * groups.json - a json file containing all groups organizin meetings
+
+Alternatively you can run the "menu" script which will present a
+command line menu allowing you to work with the events list.
+
+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.
+
+If you use this script be respectful of the included API key.
+
 # Docker Container #
 
 A Docker container is provided to make it as easy as possible to work
-with these scripts.
+with these scripts. To use it you must first install Docker.
 
 To build the container:
 
@@ -14,21 +46,8 @@ To run the container:
 
     $ docker run events
 
-By default this runs the get_meetups script (which at the time of
-writing is the only script availble).
-
-# get_meetups #
-
-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 apache.org/events/meetups.mdtext
-
-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.
-
-If you use this script be respectful of the included API key.
+By default this runs a curses menu from which you can manage the events
+list.
 
 ## Working with the results ##
 
@@ -44,9 +63,10 @@ or you can mount your client directory i
 
 Will put you in a bash shell in the container, from there you can run:
 
-    $ python getmeetups
+    $ python menu
 
-and view the files before exiting the container.
+and view the files in the containers file system before exiting the
+container.
 
 ### Mounting a host directory ###
 
@@ -54,3 +74,12 @@ and view the files before exiting the co
 
 This will run the script as normal but since you have mounted your host
 directory the files will be accessible from the host.
+
+## Development using the Docker Container ##
+
+Edit the files on your host machine and then:
+
+    $ docker run -it -v /path/to/host/directory:/project events
+
+The results will be available on your host machine.
+



Mime
View raw message