Skip to content

Commit c70d0cf

Browse files
committed
---
yaml --- r: 2611 b: refs/heads/master c: 49b90d3 h: refs/heads/master i: 2609: b7507d9 2607: 3107ca8 v: v3
1 parent 98bc24a commit c70d0cf

File tree

4 files changed

+44
-6
lines changed

4 files changed

+44
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: aed235e348cddb47c2e2e24a9a64575a524ac8c3
2+
refs/heads/master: 49b90d37eddc0b1fc518f44ce9bc7eafcde77ba4

trunk/src/etc/get-snapshot.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
import os, tarfile, hashlib, re, shutil
44
from snapshot import *
55

6-
def snap_filename_hash_part(snap):
7-
match = re.match(r".*([a-fA-F\d]{40}).tar.bz2$", snap)
8-
if not match:
9-
raise Exception("unable to find hash in filename: " + snap)
10-
return match.group(1)
116

127
def unpack_snapshot(snap):
138
dl_path = os.path.join(download_dir_base, snap)

trunk/src/etc/mirror-all-snapshots.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
3+
import os, tarfile, hashlib, re, shutil
4+
from snapshot import *
5+
6+
f = open(snapshotfile)
7+
date = None
8+
rev = None
9+
platform = None
10+
snap = None
11+
i = 0
12+
13+
for line in f.readlines():
14+
i += 1
15+
parsed = parse_line(i, line)
16+
if (not parsed): continue
17+
18+
if parsed["type"] == "snapshot":
19+
date = parsed["date"]
20+
rev = parsed["rev"]
21+
22+
elif rev != None and parsed["type"] == "file":
23+
platform = parsed["platform"]
24+
hsh = parsed["hash"]
25+
snap = full_snapshot_name(date, rev, platform, hsh)
26+
dl = os.path.join(download_dir_base, snap)
27+
url = download_url_base + "/" + snap
28+
if (not os.path.exists(dl)):
29+
print("downloading " + url)
30+
get_url_to_file(url, dl)
31+
if (snap_filename_hash_part(snap) == hash_file(dl)):
32+
print("got download with ok hash")
33+
else:
34+
raise Exception("bad hash on download")
35+
36+
37+

trunk/src/etc/snapshot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ def local_rev_committer_date():
9595
def get_url_to_file(u,f):
9696
subprocess.check_call(["curl", "-o", f, u])
9797

98+
def snap_filename_hash_part(snap):
99+
match = re.match(r".*([a-fA-F\d]{40}).tar.bz2$", snap)
100+
if not match:
101+
raise Exception("unable to find hash in filename: " + snap)
102+
return match.group(1)
103+
98104
def hash_file(x):
99105
h = hashlib.sha1()
100106
h.update(open(x, "rb").read())

0 commit comments

Comments
 (0)