diff options
| author | Richo Healey <richo@psych0tik.net> | 2015-01-27 00:10:27 -0800 |
|---|---|---|
| committer | Richo Healey <richo@psych0tik.net> | 2015-01-27 01:09:38 -0800 |
| commit | 958dea1745b9000becaeed728f78daec3b9c13ba (patch) | |
| tree | 9d9645dadf065126d75cd9e27c0f9d3e4758ae81 /src/etc | |
| parent | f230683b1a01500af3f74e3e357441c67b77c4b6 (diff) | |
make get-snapshot externally usable
Diffstat (limited to 'src/etc')
| -rwxr-xr-x | src/etc/get-snapshot.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/etc/get-snapshot.py b/src/etc/get-snapshot.py index 442c50ed773..432c6b24946 100755 --- a/src/etc/get-snapshot.py +++ b/src/etc/get-snapshot.py @@ -48,23 +48,27 @@ def unpack_snapshot(triple, dl_path): # The first is the O/S triple. # The second is an optional path to the snapshot to use. -triple = sys.argv[1] -if len(sys.argv) == 3: - dl_path = sys.argv[2] -else: - snap = determine_curr_snapshot(triple) - dl = os.path.join(download_dir_base, snap) - url = download_url_base + "/" + snap - print("determined most recent snapshot: " + snap) +def main(argv): + triple = argv[1] + if len(argv) == 3: + dl_path = argv[2] + else: + snap = determine_curr_snapshot(triple) + dl = os.path.join(download_dir_base, snap) + url = download_url_base + "/" + snap + print("determined most recent snapshot: " + snap) - if (not os.path.exists(dl)): - get_url_to_file(url, dl) + if (not os.path.exists(dl)): + 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") + if (snap_filename_hash_part(snap) == hash_file(dl)): + print("got download with ok hash") + else: + raise Exception("bad hash on download") + + dl_path = os.path.join(download_dir_base, snap) - dl_path = os.path.join(download_dir_base, snap) + unpack_snapshot(triple, dl_path) -unpack_snapshot(triple, dl_path) +if __name__ == '__main__': + main(sys.argv) |
