equal
deleted
inserted
replaced
17 # fields enclosed by brackets "[]" replaced with your own identifying |
17 # fields enclosed by brackets "[]" replaced with your own identifying |
18 # information: Portions Copyright [yyyy] [name of copyright owner] |
18 # information: Portions Copyright [yyyy] [name of copyright owner] |
19 # |
19 # |
20 # CDDL HEADER END |
20 # CDDL HEADER END |
21 # |
21 # |
22 # Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. |
22 # Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. |
23 # |
23 # |
24 # |
24 # |
25 # fetch.py - a file download utility |
25 # fetch.py - a file download utility |
26 # |
26 # |
27 # A simple program similiar to wget(1), but handles local file copy, ignores |
27 # A simple program similiar to wget(1), but handles local file copy, ignores |
43 except: |
43 except: |
44 print str(e) |
44 print str(e) |
45 |
45 |
46 def validate(file, hash): |
46 def validate(file, hash): |
47 algorithm, hashvalue = hash.split(':') |
47 algorithm, hashvalue = hash.split(':') |
|
48 |
|
49 # force migration away from sha1 |
|
50 if algorithm == "sha1": |
|
51 algorithm = "sha256" |
48 try: |
52 try: |
49 m = hashlib.new(algorithm) |
53 m = hashlib.new(algorithm) |
50 except ValueError: |
54 except ValueError: |
51 return False |
55 return False |
52 |
56 |
77 import gzip |
81 import gzip |
78 import bz2 |
82 import bz2 |
79 |
83 |
80 expr_bz = re.compile('.+\.bz2$', re.IGNORECASE) |
84 expr_bz = re.compile('.+\.bz2$', re.IGNORECASE) |
81 expr_gz = re.compile('.+\.gz$', re.IGNORECASE) |
85 expr_gz = re.compile('.+\.gz$', re.IGNORECASE) |
|
86 expr_tgz = re.compile('.+\.tgz$', re.IGNORECASE) |
82 |
87 |
83 try: |
88 try: |
84 if expr_bz.match(filename): |
89 if expr_bz.match(filename): |
85 file = bz2.BZ2File(filename, 'r') |
90 file = bz2.BZ2File(filename, 'r') |
86 elif expr_gz.match(filename): |
91 elif expr_gz.match(filename): |
|
92 file = gzip.GzipFile(filename, 'r') |
|
93 elif expr_tgz.match(filename): |
87 file = gzip.GzipFile(filename, 'r') |
94 file = gzip.GzipFile(filename, 'r') |
88 else: |
95 else: |
89 return False |
96 return False |
90 except IOError as e: |
97 except IOError as e: |
91 printIOError(e, "Can't open archive " + filename) |
98 printIOError(e, "Can't open archive " + filename) |