source: orange/Orange/orng/downloadPyd.py @ 10382:5e48d5b6c1ef

Revision 10382:5e48d5b6c1ef, 1.2 KB checked in by Ales Erjavec <ales.erjavec@…>, 2 years ago (diff)

Fixed downloadPyd script.

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