mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-07-17 21:56:07 -04:00
Deleted code related to Streaming Features
This commit is contained in:
@@ -141,7 +141,6 @@ class Session(object):
|
||||
self.reconnection_function_active = False
|
||||
self.counter = 0
|
||||
self.lists = []
|
||||
pub.subscribe(self.add_friends, "friends-receibed")
|
||||
|
||||
@property
|
||||
def is_logged(self):
|
||||
@@ -280,10 +279,7 @@ class Session(object):
|
||||
update_function str: The function to call. This function must be child of self.twitter.twitter
|
||||
returns a list with all items retrieved."""
|
||||
|
||||
if application.streaming_lives():
|
||||
max = int(self.settings["general"]["max_api_calls"])-1
|
||||
else:
|
||||
max = 0
|
||||
max = 0
|
||||
results = []
|
||||
data = getattr(self.twitter.twitter, update_function)(count=self.settings["general"]["max_tweets_per_call"], *args, **kwargs)
|
||||
results.extend(data)
|
||||
@@ -376,51 +372,6 @@ class Session(object):
|
||||
self.db[name]["cursor"] = tl["next_cursor"]
|
||||
return num
|
||||
|
||||
def start_streaming(self):
|
||||
|
||||
""" Start the streaming for sending tweets in realtime."""
|
||||
if application.streaming_lives():
|
||||
if not hasattr(self, "main_stream"):
|
||||
self.get_timelines()
|
||||
if not hasattr(self, "timelinesStream"):
|
||||
self.get_main_stream()
|
||||
|
||||
def get_main_stream(self):
|
||||
if application.streaming_lives():
|
||||
log.debug("Starting the main stream...")
|
||||
self.main_stream = twitter.buffers.stream.streamer(keyring.get("api_key"), keyring.get("api_secret"), self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], self)
|
||||
stream_threaded(self.main_stream.user, self.session_id)
|
||||
|
||||
def get_timelines(self):
|
||||
if application.streaming_lives():
|
||||
log.debug("Starting the timelines stream...")
|
||||
self.timelinesStream = twitter.buffers.indibidual.timelinesStreamer(keyring.get("api_key"), keyring.get("api_secret"), self.settings["twitter"]["user_key"], self.settings["twitter"]["user_secret"], session=self)
|
||||
ids = ""
|
||||
for i in self.settings["other_buffers"]["timelines"]:
|
||||
ids = ids + "%s, " % (self.db[i+"-timeline"][0]["user"]["id_str"])
|
||||
for i in self.lists:
|
||||
for z in i.users:
|
||||
ids += str(z) + ", "
|
||||
if ids != "":
|
||||
stream_threaded(self.timelinesStream.statuses.filter, self.session_id, follow=ids)
|
||||
|
||||
def add_friends(self):
|
||||
if application.streaming_lives():
|
||||
try:
|
||||
self.timelinesStream.set_friends(self.main_stream.friends)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def listen_stream_error(self):
|
||||
if hasattr(self, "main_stream") and application.streaming_lives():
|
||||
log.debug("Disconnecting the main stream...")
|
||||
self.main_stream.disconnect()
|
||||
del self.main_stream
|
||||
if hasattr(self, "timelinesStream") and application.streaming_lives():
|
||||
log.debug("disconnecting the timelines stream...")
|
||||
self.timelinesStream.disconnect()
|
||||
del self.timelinesStream
|
||||
|
||||
def check_connection(self):
|
||||
log.debug("Executing check connection...")
|
||||
instan = 0
|
||||
@@ -434,27 +385,7 @@ class Session(object):
|
||||
self.counter = 0
|
||||
if self.reconnection_function_active == True: return
|
||||
self.reconnection_function_active = True
|
||||
if not hasattr(self, "main_stream") and application.streaming_lives():
|
||||
self.get_main_stream()
|
||||
if not hasattr(self, "timelinesStream") and application.streaming_lives():
|
||||
self.get_timelines()
|
||||
self.reconnection_function_active = False
|
||||
if hasattr(self, "timelinesStream") and not hasattr(self.timelinesStream, "friends"):
|
||||
self.add_friends()
|
||||
# try:
|
||||
# urllib2.urlopen("http://74.125.228.231", timeout=5)
|
||||
# except urllib2.URLError:
|
||||
# pub.sendMessage("stream-error", session=self.session_id)
|
||||
|
||||
def remove_stream(self, stream):
|
||||
if application.streaming_lives():
|
||||
if stream == "timelinesStream":
|
||||
if hasattr(self, "timelinesStream"):
|
||||
self.timelinesStream.disconnect()
|
||||
del self.timelinesStream
|
||||
else:
|
||||
self.main_stream.disconnect()
|
||||
del self.main_stream
|
||||
|
||||
def shelve(self):
|
||||
"Shelve the database to allow for persistance."
|
||||
|
Reference in New Issue
Block a user