2012-01-20 06:23:07 -06:00
|
|
|
#!/usr/bin/env python
|
2013-01-18 01:28:42 -06:00
|
|
|
# xfail-license
|
2012-01-20 06:23:07 -06:00
|
|
|
|
|
|
|
import os, tarfile, hashlib, re, shutil, sys
|
|
|
|
from snapshot import *
|
|
|
|
|
|
|
|
f = open(snapshotfile)
|
|
|
|
date = None
|
|
|
|
rev = None
|
|
|
|
platform = None
|
|
|
|
snap = None
|
|
|
|
i = 0
|
|
|
|
|
|
|
|
newestSet = {}
|
|
|
|
|
|
|
|
|
|
|
|
for line in f.readlines():
|
|
|
|
i += 1
|
|
|
|
parsed = parse_line(i, line)
|
|
|
|
if (not parsed): continue
|
|
|
|
|
|
|
|
if parsed["type"] == "snapshot":
|
|
|
|
if (len(newestSet) == 0 or parsed["date"] > newestSet["date"]):
|
2012-01-20 18:12:25 -06:00
|
|
|
newestSet["date"] = parsed["date"]
|
|
|
|
newestSet["rev"] = parsed["rev"]
|
2012-01-20 06:23:07 -06:00
|
|
|
newestSet["files"] = []
|
|
|
|
addingMode = True
|
|
|
|
else:
|
|
|
|
addingMode = False
|
|
|
|
|
|
|
|
elif addingMode == True and parsed["type"] == "file":
|
|
|
|
tux = re.compile("linux", re.IGNORECASE)
|
|
|
|
if (tux.match(parsed["platform"]) != None):
|
|
|
|
ff = {}
|
|
|
|
ff["platform"] = parsed["platform"]
|
|
|
|
ff["hash"] = parsed["hash"]
|
|
|
|
newestSet["files"] += [ff]
|
|
|
|
|
|
|
|
|
|
|
|
def download_new_file (date, rev, platform, hsh):
|
|
|
|
snap = full_snapshot_name(date, rev, platform, hsh)
|
|
|
|
dl = os.path.join(download_dir_base, snap)
|
|
|
|
url = download_url_base + "/" + snap
|
|
|
|
if (not os.path.exists(dl)):
|
|
|
|
print("downloading " + url)
|
|
|
|
get_url_to_file(url, dl)
|
|
|
|
if (snap_filename_hash_part(snap) == hash_file(dl)):
|
|
|
|
print("got download with ok hash")
|
|
|
|
else:
|
|
|
|
raise Exception("bad hash on download")
|
|
|
|
|
|
|
|
for ff in newestSet["files"]:
|
2012-01-20 18:12:25 -06:00
|
|
|
download_new_file (newestSet["date"], newestSet["rev"],
|
|
|
|
ff["platform"], ff["hash"])
|