Added disconnect to TwythonStreamer, more tests, update example
* Stream and Twython core tests * Import TwythonStreamError from twython See more in 2.10.1 section of HISTORY.rst
This commit is contained in:
parent
815393cc33
commit
c8b1202880
9 changed files with 122 additions and 55 deletions
|
|
@ -2,17 +2,15 @@ from .endpoints import twitter_http_status_codes
|
|||
|
||||
|
||||
class TwythonError(Exception):
|
||||
"""
|
||||
Generic error class, catch-all for most Twython issues.
|
||||
Special cases are handled by TwythonAuthError & TwythonRateLimitError.
|
||||
"""Generic error class, catch-all for most Twython issues.
|
||||
Special cases are handled by TwythonAuthError & TwythonRateLimitError.
|
||||
|
||||
Note: Syntax has changed as of Twython 1.3. To catch these,
|
||||
you need to explicitly import them into your code, e.g:
|
||||
Note: Syntax has changed as of Twython 1.3. To catch these,
|
||||
you need to explicitly import them into your code, e.g:
|
||||
|
||||
from twython import (
|
||||
TwythonError, TwythonRateLimitError, TwythonAuthError
|
||||
)
|
||||
"""
|
||||
from twython import (
|
||||
TwythonError, TwythonRateLimitError, TwythonAuthError
|
||||
)"""
|
||||
def __init__(self, msg, error_code=None, retry_after=None):
|
||||
self.error_code = error_code
|
||||
|
||||
|
|
@ -30,18 +28,16 @@ class TwythonError(Exception):
|
|||
|
||||
|
||||
class TwythonAuthError(TwythonError):
|
||||
""" Raised when you try to access a protected resource and it fails due to
|
||||
some issue with your authentication.
|
||||
"""
|
||||
"""Raised when you try to access a protected resource and it fails due to
|
||||
some issue with your authentication."""
|
||||
pass
|
||||
|
||||
|
||||
class TwythonRateLimitError(TwythonError):
|
||||
""" Raised when you've hit a rate limit.
|
||||
"""Raised when you've hit a rate limit.
|
||||
|
||||
The amount of seconds to retry your request in will be appended
|
||||
to the message.
|
||||
"""
|
||||
The amount of seconds to retry your request in will be appended
|
||||
to the message."""
|
||||
def __init__(self, msg, error_code, retry_after=None):
|
||||
if isinstance(retry_after, int):
|
||||
msg = '%s (Retry after %d seconds)' % (msg, retry_after)
|
||||
|
|
@ -49,5 +45,5 @@ class TwythonRateLimitError(TwythonError):
|
|||
|
||||
|
||||
class TwythonStreamError(TwythonError):
|
||||
"""Test"""
|
||||
"""Raised when an invalid response from the Stream API is received"""
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue