Logo Search packages:      
Sourcecode: babiloo version File versions  Download package

downloader.py

#!/usr/bin/env python

__author__="Andrew Pennebaker (andrew.pennebaker@gmail.com)"
__date__="3 Nov 2005 - 14 Feb 2007"
__copyright__="Copyright 2006 2007 Andrew Pennebaker"
__license__="GPL"
__version__="0.5"
__URL__="http://snippets.dzone.com/posts/show/2887"

from urllib import urlopen

import os

import sys
from getopt import getopt

def getURLName(url):
      directory=os.curdir

      name="%s%s%s" % (
            directory,
            os.sep,
            url.split("/")[-1]
      )

      return name

def createDownload(url, proxy=None):
      instream=urlopen(url, None, proxy)

      filename=instream.info().getheader("Content-Length")
      if filename==None:
            filename="temp"

      return (instream, filename)

def download(instream, outstream):
      outstream.write(instream.read())

      outstream.close()

Generated by  Doxygen 1.6.0   Back to index