3 # Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
4 # file at the top-level directory of this distribution and at
5 # http://rust-lang.org/COPYRIGHT.
7 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
8 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
9 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
10 # option. This file may not be copied, modified, or distributed
11 # except according to those terms.
15 from snapshot import *
17 f = open(snapshotfile)
27 for line in f.readlines():
29 parsed = parse_line(i, line)
33 if parsed["type"] == "snapshot":
34 if (len(newestSet) == 0 or parsed["date"] > newestSet["date"]):
35 newestSet["date"] = parsed["date"]
36 newestSet["rev"] = parsed["rev"]
37 newestSet["files"] = []
42 elif addingMode is True and parsed["type"] == "file":
43 tux = re.compile("linux", re.IGNORECASE)
44 if (tux.match(parsed["platform"]) is not None):
46 ff["platform"] = parsed["platform"]
47 ff["hash"] = parsed["hash"]
48 newestSet["files"] += [ff]
51 def download_new_file(date, rev, platform, hsh):
52 snap = full_snapshot_name(date, rev, platform, hsh)
53 dl = os.path.join(download_dir_base, snap)
54 url = download_url_base + "/" + snap
55 if (not os.path.exists(dl)):
56 print("downloading " + url)
57 get_url_to_file(url, dl)
58 if (snap_filename_hash_part(snap) == hash_file(dl)):
59 print("got download with ok hash")
61 raise Exception("bad hash on download")
63 for ff in newestSet["files"]:
64 download_new_file(newestSet["date"], newestSet["rev"],
65 ff["platform"], ff["hash"])