Merge lp:~mhall119/summit/push-registration-script into lp:summit

Proposed by Michael Hall
Status: Merged
Approved by: Chris Johnston
Approved revision: 555
Merged at revision: 555
Proposed branch: lp:~mhall119/summit/push-registration-script
Merge into: lp:summit
Diff against target: 48 lines (+43/-0)
1 file modified
scripts/push_registered_to_launchpad.py (+43/-0)
To merge this branch: bzr merge lp:~mhall119/summit/push-registration-script
Reviewer Review Type Date Requested Status
Chris Johnston Approve
Review via email: mp+163827@code.launchpad.net

Commit message

Add utility script to push Summit-only registrations back to Launchpad

Description of the change

Add utility script to push Summit-only registrations back to Launchpad

To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'scripts'
2=== added file 'scripts/push_registered_to_launchpad.py'
3--- scripts/push_registered_to_launchpad.py 1970-01-01 00:00:00 +0000
4+++ scripts/push_registered_to_launchpad.py 2013-05-15 03:09:25 +0000
5@@ -0,0 +1,43 @@
6+#! /usr/bin/python
7+
8+import httplib2
9+import urllib
10+import simplejson
11+
12+# Configure these before running
13+LP_COOKIE = 'lp=replace-with-yours'
14+LP_HOST = 'launchpad.net'
15+SPRINT_NAME = 'uds-1305'
16+SPRINT_START = '2013-05-14 14:00'
17+SPRINT_END = '2013-05-16 20:00'
18+# Leave the rest alone
19+
20+client = httplib2.Http()
21+resp, data = client.request('http://summit.ubuntu.com/api/user/?attendee__summit__name=%s&attendee__from_launchpad=0' % SPRINT_NAME)
22+
23+users = simplejson.loads(data)
24+
25+register_url = 'https://%s/sprints/%s/+register' % (LP_HOST, SPRINT_NAME)
26+headers = {
27+ 'Cookie': LP_COOKIE,
28+ 'Referer': 'https://%s/sprints/%s/+register' % (LP_HOST, SPRINT_NAME),
29+ }
30+
31+# Used to limit the http calls during testing
32+#users = [{'username': 'cjohnston'}]
33+
34+for user in users:
35+ print 'Rgistering %s' % user['username']
36+ post_data = urllib.urlencode({
37+ 'field.attendee': user['username'],
38+ 'field.time_starts': SPRINT_START,
39+ 'field.time_ends': SPRINT_END,
40+ 'field.is_physical': 'no',
41+ 'field.is_physical-empty-marker': 1,
42+ 'field.actions.register': 'Register',
43+ })
44+ resp, data = client.request(register_url, method='POST', body=post_data, headers=headers)
45+ if resp['status'] != '200':
46+ print 'Failed to register user: %s' % user['username']
47+exit
48+

Subscribers

People subscribed via source and target branches