source: orange/orange/downloadPyd.py @ 7745:6c1f363bd6fa

Revision 7745:6c1f363bd6fa, 1.1 KB checked in by lanz <lan.zagar@…>, 3 years ago (diff)

Changed downloadPyd.py so that it doesn't crash if you have a .pyd not on the server.

Line 
1import urllib, sys, os, md5
2
3files = "orange", "corn", "statc", "orangeom", "orangene", "_orngCRS"
4baseurl = "http://www.ailab.si/orange/download/binaries/%i%i/" % sys.version_info[:2]
5fleurl = baseurl + "%s.pyd"
6
7op = filter(lambda x:x[-7:].lower() in ["\\orange", "/orange"], sys.path)
8if not op:
9    print "Orange is not found on the Python's path"
10
11print "Downloading to %s (for Python %i.%i)" % (op[0], sys.version_info[0], sys.version_info[1])
12os.chdir(op[0])
13
14def rep(blk_cnt, blk_size, tot_size):
15    print "\rDownloading %s: %i of %i" % (fle, min(tot_size, blk_cnt*blk_size), tot_size),
16
17repository_stamps = dict([tuple(x.split()) for x in urllib.urlopen(baseurl + "stamps_pyd.txt") if x.strip()])
18
19for fle in files:
20    if os.path.exists(fle+".pyd") and repository_stamps.get(fle+".pyd", "") == md5.md5(file(fle+".pyd", "rb").read()).hexdigest().upper():
21        print "\nSkipping %s" % fle,
22    else:
23        print "\nDownloading %s" % fle,
24        urllib.urlretrieve(fleurl % fle, fle+".temp", rep)
25        if os.path.exists(fle+".pyd"):
26            os.remove(fle+".pyd")
27        os.rename(fle+".temp", fle+".pyd")
Note: See TracBrowser for help on using the repository browser.