Replace use of print with Python's logging infrastructure.
[feedingit] / src / httpprogresshandler.py
index 78eb39c..7c4fe63 100644 (file)
@@ -18,6 +18,8 @@
 import urllib2 
 import httplib
 import time
+import logging
+logger = logging.getLogger(__name__)
 
 class ProgressSocket(object):
     """
@@ -28,7 +30,8 @@ class ProgressSocket(object):
         self.connection = connection
 
     def __getattribute__(self, attr):
-        # print "%s.__getattribute__(%s)" % (self.__class__.__name__, attr)
+        # logger.debug("%s.__getattribute__(%s)"
+        #              % (self.__class__.__name__, attr))
 
         def send(data):
             # 100k at a time.
@@ -124,15 +127,16 @@ if __name__ == '__main__':
         cstats = connection.stats
         ostats = connection.opener.stats
 
-        print (("%s: connection: %d sent, %d received: %d kb/s; "
-                + "opener: %d sent, %d received, %d kb/s")
-               % (req,
-                  cstats['sent'], cstats['received'],
-                  ((cstats['sent'] + cstats['received'])
-                   / (time.time() - cstats['started']) / 1024),
-                  ostats['sent'], ostats['received'],
-                  ((ostats['sent'] + ostats['received'])
-                   / (time.time() - ostats['started']) / 1024)))
+        print(
+            ("%s: connection: %d sent, %d received: %d kb/s; "
+             + "opener: %d sent, %d received, %d kb/s")
+            % (req,
+               cstats['sent'], cstats['received'],
+               ((cstats['sent'] + cstats['received'])
+                / (time.time() - cstats['started']) / 1024),
+               ostats['sent'], ostats['received'],
+               ((ostats['sent'] + ostats['received'])
+                / (time.time() - ostats['started']) / 1024)))
 
     opener = urllib2.build_opener(HTTPProgressHandler(callback))