Back to index

apport  2.3
Public Member Functions
apport.crashdb_impl.launchpad.HTTPSProgressConnection Class Reference
Inheritance diagram for apport.crashdb_impl.launchpad.HTTPSProgressConnection:
Inheritance graph
[legend]
Collaboration diagram for apport.crashdb_impl.launchpad.HTTPSProgressConnection:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def send

Detailed Description

Implement a HTTPSConnection with an optional callback function for
upload progress.

Definition at line 956 of file launchpad.py.


Member Function Documentation

Definition at line 960 of file launchpad.py.

00960 
00961     def send(self, data):
00962         global _https_upload_callback
00963 
00964         # if callback has not been set, call the old method
00965         if not _https_upload_callback:
00966             HTTPSConnection.send(self, data)
00967             return
00968 
00969         sent = 0
00970         total = len(data)
00971         chunksize = 1024
00972         while sent < total:
00973             _https_upload_callback(sent, total)
00974             t1 = time.time()
00975             HTTPSConnection.send(self, data[sent:(sent + chunksize)])
00976             sent += chunksize
00977             t2 = time.time()
00978 
00979             # adjust chunksize so that it takes between .5 and 2
00980             # seconds to send a chunk
00981             if chunksize > 1024:
00982                 if t2 - t1 < .5:
00983                     chunksize <<= 1
00984                 elif t2 - t1 > 2:
00985                     chunksize >>= 1
00986 


The documentation for this class was generated from the following file: