Updated AUTHORS, HISTORY; added ssl_verify; removed _media_update

- Added @jvanasco to the AUTHORS.rst
- Updated History
- Removed _media_update internal function
- Twython now takes ssl_verify param
This commit is contained in:
Mike Helmick 2013-04-23 19:43:05 -04:00
parent a451db43c1
commit 776e02b071
4 changed files with 30 additions and 23 deletions

View file

@ -38,3 +38,4 @@ Patches and Suggestions
- `Virendra Rajput <https://github.com/bkvirendra>`_, Fixed unicode (json) encoding in twython.py 2.7.2. - `Virendra Rajput <https://github.com/bkvirendra>`_, Fixed unicode (json) encoding in twython.py 2.7.2.
- `Paul Solbach <https://github.com/hansenrum>`_, fixed requirement for oauth_verifier - `Paul Solbach <https://github.com/hansenrum>`_, fixed requirement for oauth_verifier
- `Greg Nofi <https://github.com/nofeet>`_, fixed using built-in Exception attributes for storing & retrieving error message - `Greg Nofi <https://github.com/nofeet>`_, fixed using built-in Exception attributes for storing & retrieving error message
- `Jonathan Vanasco <https://github.com/jvanasco>`_, Debugging support, error_code tracking, Twitter error API tracking, other fixes

View file

@ -1,7 +1,7 @@
History History
------- -------
2.8.0 (2013-xx-xx) 2.8.0 (2013-04-29)
++++++++++++++++++ ++++++++++++++++++
- Added a ``HISTORY.rst`` to start tracking history of changes - Added a ``HISTORY.rst`` to start tracking history of changes
@ -25,6 +25,8 @@ just define it
- Removed `bulkUserLookup` (please use `lookupUser` instead), removed `getProfileImageUrl` (will be completely removed from Twitter API on May 7th, 2013) - Removed `bulkUserLookup` (please use `lookupUser` instead), removed `getProfileImageUrl` (will be completely removed from Twitter API on May 7th, 2013)
- Updated shortenUrl to actually work for those using it, but it is being deprecated since `requests` makes it easy for developers to implement their own url shortening in their app (see https://github.com/ryanmcgrath/twython/issues/184) - Updated shortenUrl to actually work for those using it, but it is being deprecated since `requests` makes it easy for developers to implement their own url shortening in their app (see https://github.com/ryanmcgrath/twython/issues/184)
- Twython Deprecation Warnings will now be seen in shell when using Python 2.7 and greater - Twython Deprecation Warnings will now be seen in shell when using Python 2.7 and greater
- Twython now takes ``ssl_verify`` parameter, defaults True. Set False if you're having development server issues
- Removed internal ``_media_update`` function, we could have always just used ``self.post``
2.7.3 (2013-04-12) 2.7.3 (2013-04-12)
++++++++++++++++++ ++++++++++++++++++

View file

@ -25,7 +25,7 @@ setup(
include_package_data=True, include_package_data=True,
# Package dependencies. # Package dependencies.
install_requires=['requests>=1.0.0, <2.0.0', 'requests_oauthlib==0.3.0'], install_requires=['requests==1.2.0', 'requests_oauthlib==0.3.0'],
# Metadata for PyPI. # Metadata for PyPI.
author='Ryan McGrath', author='Ryan McGrath',

View file

@ -14,8 +14,10 @@ warnings.simplefilter('always', TwythonDeprecationWarning) # For Python 2.7 >
class Twython(object): class Twython(object):
def __init__(self, app_key=None, app_secret=None, oauth_token=None, oauth_token_secret=None, def __init__(self, app_key=None, app_secret=None, oauth_token=None,
headers=None, proxies=None, version='1.1', callback_url=None, twitter_token=None, twitter_secret=None): oauth_token_secret=None, headers=None, proxies=None,
version='1.1', callback_url=None, ssl_verify=True,
twitter_token=None, twitter_secret=None):
"""Instantiates an instance of Twython. Takes optional parameters for authentication and such (see below). """Instantiates an instance of Twython. Takes optional parameters for authentication and such (see below).
:param app_key: (optional) Your applications key :param app_key: (optional) Your applications key
@ -25,6 +27,7 @@ class Twython(object):
:param headers: (optional) Custom headers to send along with the request :param headers: (optional) Custom headers to send along with the request
:param callback_url: (optional) If set, will overwrite the callback url set in your application :param callback_url: (optional) If set, will overwrite the callback url set in your application
:param proxies: (optional) A dictionary of proxies, for example {"http":"proxy.example.org:8080", "https":"proxy.example.org:8081"}. :param proxies: (optional) A dictionary of proxies, for example {"http":"proxy.example.org:8080", "https":"proxy.example.org:8081"}.
:param ssl_verify: (optional) Turns off ssl verification when False. Useful if you have development server issues.
""" """
# API urls, OAuth urls and API version; needed for hitting that there API. # API urls, OAuth urls and API version; needed for hitting that there API.
@ -76,6 +79,7 @@ class Twython(object):
self.client.headers = self.headers self.client.headers = self.headers
self.client.proxies = proxies self.client.proxies = proxies
self.client.auth = self.auth self.client.auth = self.auth
self.client.verify = ssl_verify
# register available funcs to allow listing name when debugging. # register available funcs to allow listing name when debugging.
def setFunc(key): def setFunc(key):
@ -334,9 +338,6 @@ class Twython(object):
## Media Uploading functions ############################################## ## Media Uploading functions ##############################################
def _media_update(self, url, file_, **params):
return self.post(url, params=params, files=file_)
def updateProfileBackgroundImage(self, file_, version='1.1', **params): def updateProfileBackgroundImage(self, file_, version='1.1', **params):
"""Updates the authenticating user's profile background image. """Updates the authenticating user's profile background image.
@ -348,10 +349,11 @@ class Twython(object):
**params - You may pass items that are stated in this doc **params - You may pass items that are stated in this doc
(https://dev.twitter.com/docs/api/1.1/post/account/update_profile_background_image) (https://dev.twitter.com/docs/api/1.1/post/account/update_profile_background_image)
""" """
url = 'https://api.twitter.com/%s/account/update_profile_background_image.json' % version
return self._media_update(url, return self.post('account/update_profile_background_image',
{'image': (file_, open(file_, 'rb'))}, params=params,
**params) files={'image': (file_, open(file_, 'rb'))},
version=version)
def updateProfileImage(self, file_, version='1.1', **params): def updateProfileImage(self, file_, version='1.1', **params):
"""Updates the authenticating user's profile image (avatar). """Updates the authenticating user's profile image (avatar).
@ -363,10 +365,11 @@ class Twython(object):
**params - You may pass items that are stated in this doc **params - You may pass items that are stated in this doc
(https://dev.twitter.com/docs/api/1.1/post/account/update_profile_image) (https://dev.twitter.com/docs/api/1.1/post/account/update_profile_image)
""" """
url = 'https://api.twitter.com/%s/account/update_profile_image.json' % version
return self._media_update(url, return self.post('account/update_profile_image',
{'image': (file_, open(file_, 'rb'))}, params=params,
**params) files={'image': (file_, open(file_, 'rb'))},
version=version)
def updateStatusWithMedia(self, file_, version='1.1', **params): def updateStatusWithMedia(self, file_, version='1.1', **params):
"""Updates the users status with media """Updates the users status with media
@ -379,10 +382,10 @@ class Twython(object):
(https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media) (https://dev.twitter.com/docs/api/1.1/post/statuses/update_with_media)
""" """
url = 'https://api.twitter.com/%s/statuses/update_with_media.json' % version return self.post('statuses/update_with_media',
return self._media_update(url, params=params,
{'media': (file_, open(file_, 'rb'))}, files={'media': (file_, open(file_, 'rb'))},
**params) version=version)
def updateProfileBannerImage(self, file_, version='1.1', **params): def updateProfileBannerImage(self, file_, version='1.1', **params):
"""Updates the users profile banner """Updates the users profile banner
@ -394,10 +397,11 @@ class Twython(object):
**params - You may pass items that are taken in this doc **params - You may pass items that are taken in this doc
(https://dev.twitter.com/docs/api/1.1/post/account/update_profile_banner) (https://dev.twitter.com/docs/api/1.1/post/account/update_profile_banner)
""" """
url = 'https://api.twitter.com/%s/account/update_profile_banner.json' % version
return self._media_update(url, return self.post('account/update_profile_banner',
{'banner': (file_, open(file_, 'rb'))}, params=params,
**params) files={'banner': (file_, open(file_, 'rb'))},
version=version)
########################################################################### ###########################################################################