1 from getpass import getpass |
1 from getpass import getpass |
2 from iri_tweet import models, utils |
2 from iri_tweet import models, utils |
3 from iri_tweet.models import TweetSource, TweetLog, ProcessEvent |
3 from iri_tweet.models import TweetSource, TweetLog, ProcessEvent |
4 from multiprocessing import (Queue as mQueue, JoinableQueue, Process, Event, |
4 from multiprocessing import (Queue as mQueue, JoinableQueue, Process, Event, |
5 get_logger) |
5 get_logger) |
6 from optparse import OptionParser |
6 from optparse import OptionParser |
7 from sqlalchemy.exc import OperationalError |
7 from sqlalchemy.exc import OperationalError |
8 from sqlalchemy.orm import scoped_session |
8 from sqlalchemy.orm import scoped_session |
9 import Queue |
9 import Queue |
185 self.logger.debug("SourceProcess : run") |
185 self.logger.debug("SourceProcess : run") |
186 track_list = self.track # or raw_input('Keywords to track (comma seperated): ').strip() |
186 track_list = self.track # or raw_input('Keywords to track (comma seperated): ').strip() |
187 track_list = [k for k in track_list.split(',')] |
187 track_list = [k for k in track_list.split(',')] |
188 |
188 |
189 self.logger.debug("SourceProcess : before connecting to stream " + repr(track_list)) |
189 self.logger.debug("SourceProcess : before connecting to stream " + repr(track_list)) |
190 stream = ReconnectingTweetStream(self.auth, track_list, reconnects=self.reconnects, as_text=True) |
190 stream = ReconnectingTweetStream(self.auth, track_list, reconnects=self.reconnects, as_text=True, url=self.options.url) |
191 self.logger.debug("SourceProcess : after connecting to stream") |
191 self.logger.debug("SourceProcess : after connecting to stream") |
192 stream.muststop = lambda: self.stop_event.is_set() |
192 stream.muststop = lambda: self.stop_event.is_set() |
193 |
193 |
194 session = self.session_maker() |
194 session = self.session_maker() |
195 |
195 |
341 help="Token file name") |
341 help="Token file name") |
342 parser.add_option("-d", "--duration", dest="duration", |
342 parser.add_option("-d", "--duration", dest="duration", |
343 help="Duration of recording in seconds", metavar="DURATION", default= -1, type='int') |
343 help="Duration of recording in seconds", metavar="DURATION", default= -1, type='int') |
344 parser.add_option("-N", "--nb-process", dest="process_nb", |
344 parser.add_option("-N", "--nb-process", dest="process_nb", |
345 help="number of process.\nIf 0, only the lefovers of the database are processed.\nIf 1, no postprocessing is done on the tweets.", metavar="PROCESS_NB", default=2, type='int') |
345 help="number of process.\nIf 0, only the lefovers of the database are processed.\nIf 1, no postprocessing is done on the tweets.", metavar="PROCESS_NB", default=2, type='int') |
|
346 parser.add_option("--url", dest="url", |
|
347 help="The twitter url to connect to.", metavar="URL", default=tweetstream.FilterStream.url) |
|
348 |
346 |
349 |
347 utils.set_logging_options(parser) |
350 utils.set_logging_options(parser) |
348 |
351 |
349 return parser.parse_args() |
352 return parser.parse_args() |
350 |
353 |