import urllib2
import httplib
import time
+import logging
+logger = logging.getLogger(__name__)
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.
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))