New package structure; twython is now separated out into core/oauth/streaming. To maintain compatibility with older Twython versions, simply import twython like: 'import twython.core as twython' - this will allow for easier oauth/streaming development, and should hopefully fix a lot of the installation issues people kept running into with easy_install
This commit is contained in:
parent
fc5aaebda3
commit
a3edbb2348
26 changed files with 35 additions and 34 deletions
52
twython/streaming/__init__.py
Normal file
52
twython/streaming/__init__.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
"""
|
||||
Yes, this is just in __init__ for now, hush.
|
||||
|
||||
The beginnings of Twitter Streaming API support in Twython. Don't expect this to work at all,
|
||||
consider it a stub for now. -- Ryan
|
||||
|
||||
Questions, comments? ryan@venodesigns.net
|
||||
"""
|
||||
|
||||
import httplib, urllib, urllib2, mimetypes, mimetools, socket, time
|
||||
|
||||
from urllib2 import HTTPError
|
||||
|
||||
try:
|
||||
import simplejson
|
||||
except ImportError:
|
||||
try:
|
||||
import json as simplejson
|
||||
except ImportError:
|
||||
try:
|
||||
from django.utils import simplejson
|
||||
except:
|
||||
raise Exception("Twython (Streaming) requires the simplejson library (or Python 2.6) to work. http://www.undefined.org/python/")
|
||||
|
||||
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
|
||||
__version__ = "0.1"
|
||||
|
||||
class TwythonStreamingError(Exception):
|
||||
def __init__(self, msg):
|
||||
self.msg = msg
|
||||
def __str__(self):
|
||||
return repr(self.msg)
|
||||
|
||||
feeds = {
|
||||
"firehose": "http://stream.twitter.com/firehose.json",
|
||||
"gardenhose": "http://stream.twitter.com/gardenhose.json",
|
||||
"spritzer": "http://stream.twitter.com/spritzer.json",
|
||||
"birddog": "http://stream.twitter.com/birddog.json",
|
||||
"shadow": "http://stream.twitter.com/shadow.json",
|
||||
"follow": "http://stream.twitter.com/follow.json",
|
||||
"track": "http://stream.twitter.com/track.json",
|
||||
}
|
||||
|
||||
class stream:
|
||||
def __init__(self, username = None, password = None, feed = "spritzer", user_agent = "Twython Streaming"):
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.feed = feeds[feed]
|
||||
self.user_agent = user_agent
|
||||
self.connection_open = False
|
||||
BIN
twython/streaming/__init__.pyc
Normal file
BIN
twython/streaming/__init__.pyc
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue