mirror of
https://github.com/balkian/bitter.git
synced 2024-12-22 00:18:12 +00:00
Fix README
This commit is contained in:
parent
7c829ee102
commit
57eb73b53b
@ -1,4 +1,5 @@
|
|||||||
#Description
|
# Description
|
||||||
|
|
||||||
There are two parts to bitter.
|
There are two parts to bitter.
|
||||||
First of all, it is a wrapper over Python twitter that adds support for several Twitter API credentials (e.g. authorizing the same app with different user accounts).
|
First of all, it is a wrapper over Python twitter that adds support for several Twitter API credentials (e.g. authorizing the same app with different user accounts).
|
||||||
Secondly, it is a command line tool to automate several actions (e.g. downloading user networks) using the wrapper.
|
Secondly, it is a command line tool to automate several actions (e.g. downloading user networks) using the wrapper.
|
||||||
|
@ -393,7 +393,7 @@ def stream(ctx):
|
|||||||
@stream.command('get')
|
@stream.command('get')
|
||||||
@click.option('-l', '--locations', default=None)
|
@click.option('-l', '--locations', default=None)
|
||||||
@click.option('-t', '--track', default=None)
|
@click.option('-t', '--track', default=None)
|
||||||
@click.option('-f', '--file', help='File to store the stream of tweets')
|
@click.option('-f', '--file', default=None, help='File to store the stream of tweets')
|
||||||
@click.option('-p', '--politelyretry', help='Politely retry after a hangup/connection error', is_flag=True, default=True)
|
@click.option('-p', '--politelyretry', help='Politely retry after a hangup/connection error', is_flag=True, default=True)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def get_stream(ctx, locations, track, file, politelyretry):
|
def get_stream(ctx, locations, track, file, politelyretry):
|
||||||
@ -416,10 +416,14 @@ def get_stream(ctx, locations, track, file, politelyretry):
|
|||||||
iterator = wq.statuses.sample()
|
iterator = wq.statuses.sample()
|
||||||
else:
|
else:
|
||||||
iterator = wq.statuses.filter(**query_args)#"-4.25,40.16,-3.40,40.75")
|
iterator = wq.statuses.filter(**query_args)#"-4.25,40.16,-3.40,40.75")
|
||||||
for i in iterator:
|
try:
|
||||||
yield i
|
for i in iterator:
|
||||||
if not politelyretry:
|
yield i
|
||||||
return
|
if not politelyretry:
|
||||||
|
return
|
||||||
|
except Exception:
|
||||||
|
if not politelyretry:
|
||||||
|
raise ex
|
||||||
thishangup = time.time()
|
thishangup = time.time()
|
||||||
if thishangup - lasthangup < 60:
|
if thishangup - lasthangup < 60:
|
||||||
raise Exception('Too many hangups in a row.')
|
raise Exception('Too many hangups in a row.')
|
||||||
|
@ -155,17 +155,24 @@ def get_hashtags(iter_tweets, best=None):
|
|||||||
|
|
||||||
|
|
||||||
def read_file(filename, tail=False):
|
def read_file(filename, tail=False):
|
||||||
with open(filename) as f:
|
if filename == '-':
|
||||||
while True:
|
f = sys.stdin
|
||||||
line = f.readline()
|
else:
|
||||||
if line not in (None, '', '\n'):
|
f = open(filename)
|
||||||
tweet = json.loads(line.strip())
|
try:
|
||||||
yield tweet
|
while True:
|
||||||
else:
|
line = f.readline()
|
||||||
if tail:
|
if line not in (None, '', '\n'):
|
||||||
time.sleep(1)
|
tweet = json.loads(line.strip())
|
||||||
else:
|
yield tweet
|
||||||
return
|
else:
|
||||||
|
if tail:
|
||||||
|
time.sleep(1)
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
finally:
|
||||||
|
if f != sys.stdin:
|
||||||
|
close(f)
|
||||||
|
|
||||||
|
|
||||||
def get_users(wq, ulist, by_name=False, queue=None, max_users=100):
|
def get_users(wq, ulist, by_name=False, queue=None, max_users=100):
|
||||||
|
Loading…
Reference in New Issue
Block a user