Skip to content

Commit a5686a4

Browse files
committed
* Switch from httplib2 to requests
* Prepare for release 0.0.5
1 parent e15ba7c commit a5686a4

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

docs/changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ Changelog
44
Releases
55
--------
66

7+
* `Release 0.0.5 - November 6, 2011`_
78
* `Release 0.0.4 - August 21, 2011`_
89
* `Release 0.0.3 - August 13, 2011`_
910
* `Release 0.0.2 - August 13, 2011`_
1011
* `Release 0.0.1 - August 7, 2011`_
1112

13+
Release 0.0.5 - November 6, 2011
14+
--------------------------------
15+
16+
* Removed explicit dependency on distribute version 0.6.14.
17+
* Switch from httplib2 to requests.
18+
1219
Release 0.0.4 - August 21, 2011
1320
-------------------------------
1421

pythonkc_meetups/client.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
from pythonkc_meetups.parsers import parse_event
1414
from pythonkc_meetups.parsers import parse_member_from_rsvp
1515
from pythonkc_meetups.parsers import parse_photo
16-
import httplib2
1716
import json
1817
import mimeparse
18+
import requests
1919
import urllib
2020

2121

@@ -196,15 +196,15 @@ def _http_get_json(self, url):
196196
* PythonKCMeetupsRateLimitExceeded
197197
198198
"""
199-
response, content = self._http_get(url)
199+
response = self._http_get(url)
200200

201-
content_type = response['content-type']
201+
content_type = response.headers['content-type']
202202
parsed_mimetype = mimeparse.parse_mime_type(content_type)
203203
if parsed_mimetype[1] not in ('json', 'javascript'):
204204
raise PythonKCMeetupsNotJson(content_type)
205205

206206
try:
207-
return json.loads(content)
207+
return json.loads(response.content)
208208
except ValueError as e:
209209
raise PythonKCMeetupsBadJson(e)
210210

@@ -220,8 +220,7 @@ def _http_get(self, url):
220220
221221
Returns
222222
-------
223-
A tuple of response, content, where response is a dictionary of
224-
response metadata (headers), and content is the entity body returned.
223+
An HTTP response, containing response headers and content.
225224
226225
Exceptions
227226
----------
@@ -231,21 +230,20 @@ def _http_get(self, url):
231230
232231
"""
233232
for try_number in range(self._http_retries + 1):
234-
client = httplib2.Http(timeout=self._http_timeout)
235-
response, content = client.request(url, 'GET')
236-
if response.status == 200:
237-
return response, content
233+
response = requests.get(url, timeout=self._http_timeout)
234+
if response.status_code == 200:
235+
return response
238236

239237
if (try_number >= self._http_retries or
240-
response.status not in (408, 500, 502, 503, 504)):
238+
response.status_code not in (408, 500, 502, 503, 504)):
241239

242-
if response.status >= 500:
243-
raise PythonKCMeetupsMeetupDown(response, content)
244-
if response.status == 400:
240+
if response.status_code >= 500:
241+
raise PythonKCMeetupsMeetupDown(response, response.content)
242+
if response.status_code == 400:
245243
try:
246244
data = json.loads(content)
247245
if data.get('code', None) == 'limit':
248246
raise PythonKCMeetupsRateLimitExceeded
249247
except: # Don't lose original error when JSON is bad
250248
pass
251-
raise PythonKCMeetupsBadResponse(response, content)
249+
raise PythonKCMeetupsBadResponse(response, response.content)

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
distribute==0.6.14
2-
httplib2==0.7.1
1+
requests==0.7.5
32
mimeparse==0.1.3
43
python-dateutil==1.5

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
setup(
99
name='pythonkc-meetups',
10-
version='0.0.4',
10+
version='0.0.5',
1111
description='Provides PythonKC Meetup.com events.',
1212
license='MIT',
1313
url='https://github.com/pythonkc/pythonkc-meetups',
1414
packages=find_packages(),
15-
install_requires=['distribute>=0.6.14', 'httplib2>=0.7.1',
15+
install_requires=['distribute', 'requests>=0.7.5',
1616
'mimeparse>=0.1.3', 'python-dateutil>=1.5,<2'],
1717
author='Steven Cummings',
1818
author_email='estebistec@gmail.com',

0 commit comments

Comments
 (0)