commit
850e630082
5 changed files with 26 additions and 31 deletions
32
.travis.yml
32
.travis.yml
|
|
@ -3,34 +3,20 @@ python:
|
||||||
- 2.6
|
- 2.6
|
||||||
- 2.7
|
- 2.7
|
||||||
- 3.3
|
- 3.3
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- secure: |-
|
- secure: USjLDneiXlVvEjkUVqTt+LBi0XJ4QhkRcJzqVXA9gEau1NTjAkNTPmHjUbOygp0dkfoV0uWrZKCw6fL1g+HJgWl0vHeHzcNl4mUkA+OwkGFHgaeIhvUfnyyJA8P3Zm21XHC+ehzMpEFN5fVNNhREjnRj+CXMc0FgA6knwBRobu4=
|
||||||
ICEoq4tQdOCGzpQAgLHunOflhLqs7hb1xYuD6mXZCbO/L+hDI4+pImA9mZZd
|
- secure: HFTL8UN1GkY6/GqygpgzWpYdWvhXRN8uTO//AgGzSg0FkHuDFcxRJigwCNI3PRImFkkRRVmUJDw18dolkx2h60w0wqD9K09DFpPTYfwmF9Bql+O3hjG9Ep9iu+CREwQTm2u66f36Q+pjaDiHWmr0kgi0zUTD7w0UvlN7gdFCMxk=
|
||||||
doyfyFMuNprWfgdUdcAL3axliRR2TyQIt51FLf7bD01jJEPa0GOKlKE/s/+3
|
- secure: L3nD/BEOAqGTmd8Va9bQ8MZL5gbiNWuy9TvIxCmQ5bfdlAAdq371oqXpuy90JftaloapktjjmuSrsiszWgMMB/TGDO45h1LrYQEMEmA/4JN/uly3lUk8th9Rig+blKTG0q6X6GsX8UWA0xVeLtXzkddpNAOBgpeqb33pWmFkdcM=
|
||||||
7oDs+kkSr81w9rvIqpx55nE8+DYzkh+TwDp5oAT+m/EE+lFItfk=
|
- secure: OdVG7LVqQ13RQxxEUPEMHZb0seoZUNzq+oy/K1qe4ubcupqiMh47pxnDcei6vkVpMn8QIvbG9lcV0oOREqJ+m+g3wUA5JX95liFqLNsmLMMVgP3yjYDf7KoNHckA5H5BwIYO/AFCBdwyNN0h439kwSciCbIr70UModVkvdWoFLI=
|
||||||
- secure: |-
|
- secure: RJgKNXCxQZxjkxqinv6x96hGZvfJpjOIaRpH9YUJrCZeqLbS1FUOvTWkze5nZQw4DL14zBmpGZXYC9twSYvscEGNnaEhxDKygiFfLosERRa65N57kphD0AsGNe9YAhWUGDbCxnZ0PYHc48DYxX+jPxqsQ/2bxZbXVoJg4pZFP3o=
|
||||||
LNowlSsXwgbFT0g8B4fDlBmOhycAfSxUNFiYBDn70H93WDLr9drEbE7Wl2Mv
|
|
||||||
AlGJw0kXey4K4oTV4+Bsy6gacsvCINpFk7f4ulTDHCH4MTONtG1n51RlkLW0
|
|
||||||
SAH8di1DiXR3PqRv+NKixVsgI0ZCY1B78NuvaoDL68bfu0KEdHs=
|
|
||||||
- secure: |-
|
|
||||||
kC9hGpdJJesmZZGMXEoPWK/lzIU6vUeguV/yI2jLgRin0EKPsgds0qR4737x
|
|
||||||
2Z2q1+CFUlvHkl+povGcm0/A1rkNqU0KKBcxRBu/XXRxJ3DWp7gIGsmoyWUW
|
|
||||||
68kdPOwxywZ+tj6BCD7zmStKn4I3mSzTmGKaWj8ZT0wQ91tl0Y8=
|
|
||||||
- secure: |-
|
|
||||||
Y0M90wCpDWmSdBmgPCV2N9mMSaRMdEOis5r5sfUq/5aFTB/KDaSR9scM1g+L
|
|
||||||
21OtvUBvaG1bdSzn0T+I5Fs/MkfbtTmuahogy83nsNDRpIZJmRIsHFmJw1fz
|
|
||||||
nEHD2Kbm4iLMYzrKto77KpxYSQMnc3sQKZjreaI31NLu+7raCAk=
|
|
||||||
- secure: |-
|
|
||||||
j1gePLSZF8SRcpF1AU+cBK5MSih5MrM1iGE6N7VWI0wrl+xh7wr3QLtVkAar
|
|
||||||
AeMFgwkz6QalfrKLsoUPFuNMv7vn+2CthC9pRv+NRk+4xV+37NysHFPR7JRo
|
|
||||||
xK2EC+DCiw2eJECnk9IPGQTgkVnFAQ3GLnsBSzzJ+UAkG2NjZ88=
|
|
||||||
- SCREEN_NAME=__twython__
|
- SCREEN_NAME=__twython__
|
||||||
- PROTECTED_TWITTER_1=TwythonSecure1
|
- PROTECTED_TWITTER_1=TwythonSecure1
|
||||||
- PROTECTED_TWITTER_2=TwythonSecure2
|
- PROTECTED_TWITTER_2=TwythonSecure2
|
||||||
- TEST_TWEET_ID=332992304010899457
|
- TEST_TWEET_ID=332992304010899457
|
||||||
- TEST_LIST_SLUG=team
|
- TEST_LIST_SLUG=team
|
||||||
- TEST_LIST_OWNER_SCREEN_NAME=twitterapi
|
- TEST_LIST_OWNER_SCREEN_NAME=twitterapi
|
||||||
|
- ACCESS_TOKEN_B64=U2FsdGVkX18QdBhvMNshM4PGy04tU3HLwKP+nNSoNZHKsvGLjELcWEXN2LIu/T+yngX1vGONf9lo14ElnfS4k7sfhiru8phR4+rZuBVP3bDvC2A6fXJuhuLqNhBrWqg32WQewvxLWDWBoKmnvRHg5b74GHh+IN/12tU0cBF2HK8=
|
||||||
install: pip install -r requirements.txt
|
install: pip install -r requirements.txt
|
||||||
script: nosetests -v -w tests/ --logging-filter="twython" --with-cov --cov twython --cov-config .coveragerc --cov-report term-missing
|
script: nosetests -v -w tests/ --logging-filter="twython" --with-cov --cov twython --cov-config .coveragerc --cov-report term-missing
|
||||||
notifications:
|
notifications:
|
||||||
|
|
@ -40,3 +26,5 @@ branches:
|
||||||
- master
|
- master
|
||||||
after_success:
|
after_success:
|
||||||
- coveralls
|
- coveralls
|
||||||
|
before_script:
|
||||||
|
- export ACCESS_TOKEN=$(echo $ACCESS_TOKEN_B64 | openssl enc -d -aes-256-cbc -A -a -pass env:ACCESS_TOKEN_PASS)
|
||||||
|
|
|
||||||
|
|
@ -102,8 +102,8 @@ Here is an example of sending the request through proxies:
|
||||||
|
|
||||||
client_args = {
|
client_args = {
|
||||||
'proxies': {
|
'proxies': {
|
||||||
'http': '10.0.10.1:8000',
|
'http': 'http://10.0.10.1:8000',
|
||||||
'https': '10.0.10.1:8001',
|
'https': 'https://10.0.10.1:8001',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,8 +122,8 @@ or both (and set a timeout variable):
|
||||||
'User-Agent': 'My App Name'
|
'User-Agent': 'My App Name'
|
||||||
},
|
},
|
||||||
'proxies': {
|
'proxies': {
|
||||||
'http': '10.0.10.1:8000',
|
'http': 'http://10.0.10.1:8000',
|
||||||
'https': '10.0.10.1:8001',
|
'https': 'https://10.0.10.1:8001',
|
||||||
}
|
}
|
||||||
'timeout': 300,
|
'timeout': 300,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
coverage==3.6.0
|
coverage==3.6.0
|
||||||
requests==1.2.2
|
requests==2.0.0
|
||||||
requests_oauthlib==0.3.2
|
requests_oauthlib==0.3.2
|
||||||
python-coveralls==2.1.0
|
python-coveralls==2.1.0
|
||||||
nose-cov==1.6
|
nose-cov==1.6
|
||||||
|
|
|
||||||
4
setup.py
4
setup.py
|
|
@ -6,7 +6,7 @@ import sys
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
__author__ = 'Ryan McGrath <ryan@venodesigns.net>'
|
__author__ = 'Ryan McGrath <ryan@venodesigns.net>'
|
||||||
__version__ = '3.0.0'
|
__version__ = '3.1.0'
|
||||||
|
|
||||||
packages = [
|
packages = [
|
||||||
'twython',
|
'twython',
|
||||||
|
|
@ -20,7 +20,7 @@ if sys.argv[-1] == 'publish':
|
||||||
setup(
|
setup(
|
||||||
name='twython',
|
name='twython',
|
||||||
version=__version__,
|
version=__version__,
|
||||||
install_requires=['requests==1.2.3', 'requests_oauthlib==0.3.2'],
|
install_requires=['requests==2.0.0', 'requests_oauthlib==0.3.2'],
|
||||||
author='Ryan McGrath',
|
author='Ryan McGrath',
|
||||||
author_email='ryan@venodesigns.net',
|
author_email='ryan@venodesigns.net',
|
||||||
license=open('LICENSE').read(),
|
license=open('LICENSE').read(),
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ Twitter API calls.
|
||||||
|
|
||||||
from .. import __version__
|
from .. import __version__
|
||||||
from ..compat import json, is_py3
|
from ..compat import json, is_py3
|
||||||
|
from ..helpers import _transparent_params
|
||||||
from .types import TwythonStreamerTypes
|
from .types import TwythonStreamerTypes
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
@ -21,7 +22,7 @@ import time
|
||||||
class TwythonStreamer(object):
|
class TwythonStreamer(object):
|
||||||
def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret,
|
def __init__(self, app_key, app_secret, oauth_token, oauth_token_secret,
|
||||||
timeout=300, retry_count=None, retry_in=10, client_args=None,
|
timeout=300, retry_count=None, retry_in=10, client_args=None,
|
||||||
handlers=None):
|
handlers=None, chunk_size=1):
|
||||||
"""Streaming class for a friendly streaming user experience
|
"""Streaming class for a friendly streaming user experience
|
||||||
Authentication IS required to use the Twitter Streaming API
|
Authentication IS required to use the Twitter Streaming API
|
||||||
|
|
||||||
|
|
@ -42,6 +43,9 @@ class TwythonStreamer(object):
|
||||||
[ex. headers, proxies, verify(SSL verification)]
|
[ex. headers, proxies, verify(SSL verification)]
|
||||||
:param handlers: (optional) Array of message types for which
|
:param handlers: (optional) Array of message types for which
|
||||||
corresponding handlers will be called
|
corresponding handlers will be called
|
||||||
|
|
||||||
|
:param chunk_size: (optional) Define the buffer size before data is
|
||||||
|
actually returned from the Streaming API. Default: 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.auth = OAuth1(app_key, app_secret,
|
self.auth = OAuth1(app_key, app_secret,
|
||||||
|
|
@ -85,6 +89,8 @@ class TwythonStreamer(object):
|
||||||
|
|
||||||
self.handlers = handlers if handlers else ['delete', 'limit', 'disconnect']
|
self.handlers = handlers if handlers else ['delete', 'limit', 'disconnect']
|
||||||
|
|
||||||
|
self.chunk_size = chunk_size
|
||||||
|
|
||||||
def _request(self, url, method='GET', params=None):
|
def _request(self, url, method='GET', params=None):
|
||||||
"""Internal stream request handling"""
|
"""Internal stream request handling"""
|
||||||
self.connected = True
|
self.connected = True
|
||||||
|
|
@ -92,6 +98,7 @@ class TwythonStreamer(object):
|
||||||
|
|
||||||
method = method.lower()
|
method = method.lower()
|
||||||
func = getattr(self.client, method)
|
func = getattr(self.client, method)
|
||||||
|
params, _ = _transparent_params(params)
|
||||||
|
|
||||||
def _send(retry_counter):
|
def _send(retry_counter):
|
||||||
requests_args = {}
|
requests_args = {}
|
||||||
|
|
@ -124,7 +131,7 @@ class TwythonStreamer(object):
|
||||||
while self.connected:
|
while self.connected:
|
||||||
response = _send(retry_counter)
|
response = _send(retry_counter)
|
||||||
|
|
||||||
for line in response.iter_lines():
|
for line in response.iter_lines(self.chunk_size):
|
||||||
if not self.connected:
|
if not self.connected:
|
||||||
break
|
break
|
||||||
if line:
|
if line:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue