Improve tweet recorder log info
authorYves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
Fri, 01 Jul 2011 10:06:36 +0200
changeset 206 6d642d650470
parent 205 dfda2d71838b
child 207 621fa6caec0c
Improve tweet recorder log info
script/stream/recorder_tweetstream.py
--- a/script/stream/recorder_tweetstream.py	Fri Jul 01 10:06:01 2011 +0200
+++ b/script/stream/recorder_tweetstream.py	Fri Jul 01 10:06:36 2011 +0200
@@ -8,6 +8,7 @@
 import os
 import socket
 import sys
+import time
 import tweetstream
 import tweetstream.auth
 socket._fileobject.default_bufsize = 0
@@ -106,6 +107,7 @@
                 print "Stop recording after %d seconds." % (duration)
                 break
             process_tweet(tweet, session, debug, token_filename)
+            logging.info("Tweet count: %d - current rate : %d - running : %s"%(stream.count, stream.rate, int(time.time()-stream.starttime)))
             session.commit()
     finally:
         stream.close()
@@ -149,7 +151,7 @@
     if options.new and os.path.exists(options.filename):
         os.remove(options.filename)
     
-    engine, metadata = models.setup_database('sqlite:///' + options.filename, echo=(options.debug))
+    engine, metadata = models.setup_database('sqlite:///' + options.filename, echo=(options.debug>=2))
     Session = sessionmaker(bind=engine)
     session = Session()