a pastebin project

Something

  1. #!/usr/bin/python
  2.  
  3. import httplib, time
  4. from urlparse import urlparse
  5.  
  6. loc = "http://localhost/ubuntu-7.04-desktop-i386.iso"
  7. file = open('output', 'wb')
  8.  
  9. def main():
  10.     global loc, file
  11.     connection = httplib.HTTPConnection(urlparse(loc)[1])
  12.     begin, size = 0, 10485700
  13.     place = begin
  14.     end = begin + size
  15.  
  16.     connection.request('GET', urlparse(loc)[2])
  17.     response = connection.getresponse()
  18.  
  19.     start_t = time.time()
  20.  
  21.     while True:
  22.         response.read(10485700)
  23.         break
  24.         place += len(data)
  25.         if data == '':
  26.             break
  27.         #file.write(data)
  28.         if place > end:
  29.             break
  30.  
  31.     end_t = time.time()
  32.  
  33.     connection.close()
  34.     file.close()
  35.  
  36.     return end_t - start_t
  37.  
  38. if __name__ == '__main__':
  39.     print main()

advertising

Create a Paste

Please enter your new post below (or upload a file instead):





Please note that information posted here will not expire by default. If you want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords.

fantasy-obligation
fantasy-obligation