Commit graph

63 commits

Author SHA1 Message Date
GitHub Merge Button
435c497d36 Merge 59b0386564 into 515e94c994 2012-04-08 17:20:49 -07:00
jonathan vanasco
59b0386564 Several improvements to allow for debugging , error handling :
- added twitter's http status codes to twitter_endpoints.py ( dict index on status code, value is a tuple of name + description )
- created an internal stash called '_last_call' that stores details of the last api call ( the call, response data, headers, url, etc )
- better error handling for api issues:
- - raises an error when the status code is not 200 or 304
- - raises TwythonAPILimit when a 420 rate limit code is returned
- - raises a TwythonError on other issues, setting the correct status code and using messages that are from the twitter API
- wraps a successful read in a try/except block.  there's an error i haven't been able to reproduce where invalid content can get in there, it would be nice to catch it and write a handler for it.  ( the previous functions were all introducted to allow this to be debugged )
- added a 'get_lastfunction_header' method. if the API has not been called yet , raises a TwythonError.  otherwise it attempts to return the header value twitter last sent.  useful for x-ratelimit-limit , x-ratelimit-remaining , x-ratelimit-class , x-ratelimit-reset
2012-04-08 18:37:47 -04:00
Erik
e353125ef1 Removed 'import inspect' as it is no longer needed. 2012-04-06 18:48:26 +02:00
Erik
ffb768d24d Fix adding callback_url for old style servers 2012-04-06 11:09:43 +02:00
Erik
f4c00ff996 If callback_url is not set, don't force it to 'oob' 2012-04-06 11:08:12 +02:00
Erik
e17b3ed877 Removed OAuth library callback_url detection code, as callback_url passing does not depend on that anymore. 2012-04-06 11:02:11 +02:00
Michael Helmick
23e529e167 Passing params through functions now work, bug fix version bump
For example:
Twython.getHomeTimeline(include_rts=True) was failing. Really sorry
about this. It is now fixed.
2012-03-23 15:46:19 -04:00
Michael Helmick
59b5733a86 Version Number 2012-03-21 15:27:13 -04:00
Michael Helmick
f917b6bfea PEP8 Clean up
A couple variables were wrong. Somewhere was using 'r' when 'request'
was the correct variable

Somewhere was using json.loads and not simplejson.loads
2012-03-21 15:25:25 -04:00
Michael Helmick
5eb7f29bff Dynamic Callback URL works again
Using POST to set dynamic callback_url decided to break within 3 hours
of testing it.. haha.
2012-03-21 15:19:27 -04:00
Ryan McGrath
9deced8f8b v1.5.0 release
- requests is now the default url/http library, thanks to Mike Helmick
- Initial pass at a Streaming API is now included (Twython.stream()), due to how easy
    requests makes it. Would actually be sad if we *didn't* have this... thanks, Kenneth. >_>;
- Return of shortenURL, for people who may have relied on it before.
- Deleted streaming handler that existed before but never got implemented fully.
- Exceptions now prefixed with Twython, but brought back originals with a more verbose error directing
    people to new ones, deprecate fully in future.
- Twython3k now has an OAuth fix for callback_urls, though it still relies on httplib2. Thanks @jbouvier!
- Added a list of contributors to the README files, something which I should have done long ago. Thank you all.
2012-03-21 19:21:34 +01:00
Michael Helmick
9e8bc09121 Fixes #67
Dynamic callback url
2012-03-21 11:41:27 -04:00
Michael Helmick
158bf77231 Remove httplib2 dependency, remove "shortenUrl" function, no need for urllib2 either
* Removed shortenUrl since Twitter ALWAYS shortens the URL to a t.co,
anyways.

* Since removing shortenUrl, no need for urllib2 anymore

* No need for httplib2 anymore, either
2012-03-08 12:24:03 -05:00
Michael Helmick
8630dc3f03 Twython using requests/requests-oauth 2012-03-08 12:20:04 -05:00
Michael Helmick
2f749183ab PEP8 Cleanup, More Verbosness
* Rid of a lot of libs not being used
* Changing Exceptions to prefix with "Twython", just safer in case
other apps have "AuthError", etc. for some reason.
2012-02-28 15:16:39 -05:00
Ryan McGrath
eca965715e 1.4.6 release for bug fixes - upgrade, please 2012-01-15 14:07:04 -05:00
Ryan McGrath
fcbc702ae5 Fixes an issue in the 1.4.5 point release, first pointed out by @michaelhelmick, fixed thanks to "tatz_tsuchiya". 2012-01-15 13:59:28 -05:00
Michael Helmick
401f610be5 Generic _media_update() func., added func. to update status with a photo.
* Generic _media_update() func. for the 3 media api calls

* Added func. to update status with a photo. updateStatusWithMedia()
2012-01-13 16:25:52 -05:00
Ryan McGrath
b391d502c3 Merge pull request #55 from michaelhelmick/master
Uploading profile image and profile background image, update setup required packages, removed some funcs.
2012-01-12 21:03:20 -08:00
Michael Helmick
f9d87b6fd3 Left out 'python' in hashbang, update setup to use env, too.
Left out 'python' in hashbang, update setup to use env, too.
2012-01-12 23:16:36 -05:00
Michael Helmick
e54183df9c Uploading profile image and profile background image, update setup required packages, removed some funcs.
* You can now update user profile image or user profile background
image thanks to the Python requests library.

* Updated setup to include 'requests' as a required package

* Changed to beginning hashbang to use the users environment python
version

* try/except for parse_qsl, removed try/excepts where it used
cgi.parse_qsl/urlparse.parse_sql

* Lines 161/162 (using self.consumer/token) <- this addition ended up
not being needed, but it doesn't hurt.

* updateProfileBackgroundImage() - param 'tile' is now True/False
rather than a string "true" or string "false"

* removed encode_multipart_formdata func, not needed any longer
2012-01-12 22:37:50 -05:00
Mesar Hameed
262b7441d4 Get rid of __getattr__ since the endpoints are directly
registered into Twython by the constructor.
2011-12-19 20:39:21 +00:00
Mesar Hameed
650a69ec17 Allow for easier debugging/development, by registering endpoints directly into Twython. 2011-11-24 16:02:06 +00:00
Kelly Slemko
4d4aa302d4 Modifying how error is constructed to make sure it calls init on the
super class
2011-11-09 15:39:02 -08:00
Kelly Slemko
f31446fa31 Added handling for rate limiting error from search api. Now throws
special exception which includes number of seconds to wait before trying
again.
2011-11-09 14:42:10 -08:00
Ryan McGrath
226f129edb Copy new endpoint to Twython3k, bump release 2011-10-27 02:32:28 +09:00
Ryan McGrath
d89b2735bb Version bump, fixes to the 3k build (courtesy of wescpy), decode all responses before JSON parsing, 1.4.4 release 2011-10-07 05:20:33 +09:00
kracekumar
1d8f2a8851 fixed typo 2011-10-05 08:04:44 +05:30
kracekumar
d6ac7c18f4 changed searchTwitter() -> search() and searchTwitterGen() -> searchGen() 2011-10-05 07:52:10 +05:30
kracekumar
7c5787ce26 changed searchTwitter() to search() 2011-10-03 23:39:29 +05:30
Edward Hades
5a155d4b7c Fix AttributeError in OAuth version detection.
Old versions of OAuth didn't have _version attribute, so Twython crashes
on them with AttributeError.

This version first checks if there is _version attribute. If no,
obviously it's an old version.
2011-09-08 14:39:39 +08:00
Ryan McGrath
d6d8823dc2 Fixes an issue with incompatibility with newer versions of the SimpleGeo OAuth2 library; also fixes an issue with bulkUserLookup fixes not being up on Pypi (issue #37, thanks jmalina327) 2011-08-09 18:01:17 -04:00
Ryan McGrath
a3159bd6a7 Based on a heads up from hp-lw, this appears to have been swapped on Twitter's end. No real idea why, but this fixes the call. Thanks\! 2011-04-02 18:15:08 +09:00
Ryan McGrath
c9417af4ae Merge branch 'master' of git@github.com:ryanmcgrath/twython 2011-03-30 22:38:31 +09:00
Ryan McGrath
a6d524e79d Update to 1.4.2, catch for Python 2.5 where urlparse doesn't exist (specifically for Google App Engine, which is strangely still on 2.5 2011-03-30 22:38:07 +09:00
Edward Hades
f184595ccf Allow passing arbitrary arguments to client backend.
Useful for timeout, for example.
2011-03-01 02:01:08 +08:00
Edward Hades
4e690f5568 Parameters now can be of any type.
The patch by Eugene (9133d0f10e) is nice, because you don't have to
manually encode() the parameters yourself. But it sucks a little,
because all your parameter values must be unicodes now.

Proposed patch encodes unicodes to utf-8 and allows the olde strs and
longs (I love to use longs in 'id' fields somewhy).
2011-02-28 19:30:09 +08:00
Ryan McGrath
9f8c04b0f2 Patch for Python 2.5; inspect.getargspec() doesn't return a named tuple pre-2.6, so catch on AttributeError and just check in the entire tuple. Increment to 1.4.1 and pushed to Pypi for the sake of 2.5 users. 2011-02-26 01:56:28 -05:00
Ryan McGrath
7f24324507 Updating to 1.4, pushing slew of changes up to Pypi (major thanks to Hades and eriks5 for their patches). 2011-02-26 01:14:21 -05:00
Erik Scheffers
1c12c9c7d5 Rewrote getProfileImageUrl to handle responses with status 200 (happen
when eg. a user does not exist)
2011-02-24 10:53:24 +08:00
Erik Scheffers
66e7040df6 Added documentation to getProfileImageUrl() 2011-02-24 10:53:24 +08:00
Erik Scheffers
4d524fb654 Added getProfileImageUrl() to handle "users/profile_image" api call 2011-02-02 16:58:14 +08:00
Erik Scheffers
7f93acb39e Modified blukUserLookup:
* version argument was ignored
* user_id and screen_name lists were not url-escaped, and always ended
with a trailing comma
* unknown parameter 'lol=1' removed
* allow other arguments to users/lookup to be added (kwargs)
* added http headers to request
2011-01-25 15:55:45 +08:00
Erik Scheffers
6f38c4c27d Removed debugging print statement 2011-01-19 16:41:33 +08:00
Erik Scheffers
0737c12449 Added callback_url parameter to Twython to set the URL the remote
site will use to return the request token.

Supports both OAuth 1.0 and 1.0a methods of setting the oauth_callback
parameter. For OAuth 1.0a support, a patched version of python-oauth2
is currently required (see
https://github.com/simplegeo/python-oauth2/pull/43).

Availability of OAuth 1.0a support in python-oauth2 is autodetected
and a suitable warning is given if the remote site requires it but
python-oauth2 doesn't support it.
2011-01-19 16:41:18 +08:00
Ryan McGrath
e5bef0f8e4 Fix header passing, fix isListSubscriber call never firing a request 2011-01-18 03:01:50 -05:00
Ryan McGrath
b225918165 TwythonError should go off of AttributeError instead 2011-01-18 01:43:41 -05:00
Ryan McGrath
7ac349bca4 Merge branch 'master' of git@github.com:ryanmcgrath/twython 2011-01-18 01:34:55 -05:00
Ryan McGrath
d5c34779d9 Woah, how the hell did we never notice this before? Set headers on the instance, not as a generic variable... 2011-01-17 19:50:39 -05:00
Alexander Dutton
90cba31922 Some parameters that need substituting (e.g. addListMember) contain underscores. These weren't matched by the regex, so I've added an underscore to the character group. addListMember now works. 2011-01-08 08:10:45 +08:00