replace raw print() calls with proper logging-based calls
authorHugo Hromic <hhromic@gmail.com>
Fri, 2 Sep 2016 16:01:35 +0000 (17:01 +0100)
committerHugo Hromic <hhromic@gmail.com>
Fri, 2 Sep 2016 16:01:35 +0000 (17:01 +0100)
tweepy/binder.py
tweepy/cache.py

index b96e4d3c0e61cccb907c6c80a73e1db245a3fa69..2f1a05862da4735bbf967140df07c7f49a31625c 100644 (file)
@@ -158,7 +158,7 @@ def bind_api(**config):
                                 sleep_time = self._reset_time - int(time.time())
                                 if sleep_time > 0:
                                     if self.wait_on_rate_limit_notify:
-                                        print("Rate limit reached. Sleeping for:", sleep_time)
+                                        log.warning("Rate limit reached. Sleeping for: %d" % sleep_time)
                                     time.sleep(sleep_time + 5)  # sleep for few extra sec
 
                 # if self.wait_on_rate_limit and self._reset_time is not None and \
@@ -166,7 +166,7 @@ def bind_api(**config):
                 #     sleep_time = self._reset_time - int(time.time())
                 #     if sleep_time > 0:
                 #         if self.wait_on_rate_limit_notify:
-                #             print("Rate limit reached. Sleeping for: " + str(sleep_time))
+                #             log.warning("Rate limit reached. Sleeping for: %d" % sleep_time)
                 #         time.sleep(sleep_time + 5)  # sleep for few extra sec
 
                 # Apply authentication
index 1d6cb562f945abed175fbffd352d627bd8664df2..99b7065ba8cccc8491793dd5601fac398a024be1 100644 (file)
@@ -8,6 +8,7 @@ import time
 import datetime
 import threading
 import os
+import logging
 
 try:
     import cPickle as pickle
@@ -27,6 +28,7 @@ except ImportError:
     # TODO: use win32file
     pass
 
+log = logging.getLogger('tweepy.cache')
 
 class Cache(object):
     """Cache interface"""
@@ -157,7 +159,7 @@ class FileCache(Cache):
             self._lock_file = self._lock_file_win32
             self._unlock_file = self._unlock_file_win32
         else:
-            print('Warning! FileCache locking not supported on this system!')
+            log.warning('FileCache locking not supported on this system!')
             self._lock_file = self._lock_file_dummy
             self._unlock_file = self._unlock_file_dummy