Skip to content

Commit 958dea1

Browse files
committed
make get-snapshot externally usable
1 parent f230683 commit 958dea1

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/etc/get-snapshot.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,27 @@ def unpack_snapshot(triple, dl_path):
4848
# The first is the O/S triple.
4949
# The second is an optional path to the snapshot to use.
5050

51-
triple = sys.argv[1]
52-
if len(sys.argv) == 3:
53-
dl_path = sys.argv[2]
54-
else:
55-
snap = determine_curr_snapshot(triple)
56-
dl = os.path.join(download_dir_base, snap)
57-
url = download_url_base + "/" + snap
58-
print("determined most recent snapshot: " + snap)
51+
def main(argv):
52+
triple = argv[1]
53+
if len(argv) == 3:
54+
dl_path = argv[2]
55+
else:
56+
snap = determine_curr_snapshot(triple)
57+
dl = os.path.join(download_dir_base, snap)
58+
url = download_url_base + "/" + snap
59+
print("determined most recent snapshot: " + snap)
5960

60-
if (not os.path.exists(dl)):
61-
get_url_to_file(url, dl)
61+
if (not os.path.exists(dl)):
62+
get_url_to_file(url, dl)
6263

63-
if (snap_filename_hash_part(snap) == hash_file(dl)):
64-
print("got download with ok hash")
65-
else:
66-
raise Exception("bad hash on download")
64+
if (snap_filename_hash_part(snap) == hash_file(dl)):
65+
print("got download with ok hash")
66+
else:
67+
raise Exception("bad hash on download")
68+
69+
dl_path = os.path.join(download_dir_base, snap)
6770

68-
dl_path = os.path.join(download_dir_base, snap)
71+
unpack_snapshot(triple, dl_path)
6972

70-
unpack_snapshot(triple, dl_path)
73+
if __name__ == '__main__':
74+
main(sys.argv)

0 commit comments

Comments
 (0)