All pastes #49384 Raw Edit

Miscellany

public python v1 · immutable
#49384 ·published 2006-04-14 23:13 UTC
rendered paste body
import urllib, os,re,urllib2import xbmc,xbmcguidef DownloaderClass(url):    dp = xbmcgui.DialogProgress()    dp.create("MC360","Downloading File",url)    try:        urllib.urlretrieve(url,"e:\\test25125",lambda nb, bs, fs, url=url: _pbhook(nb,bs,fs,url,dp))        return 1    except:        # OKAY DOWNLOAD CANCELD        dp.close()        return 0        def _pbhook(numblocks, blocksize, filesize, url=None,dp=None):    try:        percent = min((numblocks*blocksize*100)/filesize, 100)        print percent        dp.update(percent,"Downloading File")    except:        percent = 100        dp.update(percent)    if dp.iscanceled():         print "DOWNLOAD CANCELLED" # need to get this part working        raise IOError        url ='http://ftp.iinet.net.au/adsl.test'DownloaderClass(url)