Make sure that filler won't fail on first run because of empty data sets

This commit is contained in:
Klaus-Uwe Mitterer 2016-08-07 17:11:22 +02:00
parent 21c90eb394
commit 6b443f71c9

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
import dbtools, setuptools, time, twitools
import argparse, dbtools, setuptools, time, twitools
def getTweets(db=dbtools.dbHelper(), user=twitools.twObject().whoami(), two=twitools.twObject()):
query = "from:" + user
@ -103,12 +103,15 @@ def getFollowing(db=dbtools.dbHelper(), two=twitools.twObject(), firstrun=False)
return gained, lost
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-f", "--first", help="first run: ignore empty databases", action="store_true")
args = parser.parse_args()
db = dbtools.dbHelper()
count, last, first = getTweets(db)
print("Stored %i tweets." % count)
count, last, first = getMessages(db)
print("Stored %i messages." % count)
gained, lost = getFollowers(db)
gained, lost = getFollowers(db, firstrun=args.first)
print("Gained %i followers, lost %i." % (gained, lost))
gained, lost = getFollowing(db)
gained, lost = getFollowing(db, firstrun=args.first)
print("Started following %i, stopped following %i." % (gained, lost))