diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-05-15 03:54:40 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-05-15 03:54:40 +0200 |
commit | a83e5139eda1d4f2cb77f9b06da42f84aa5d7fc0 (patch) | |
tree | 50f40ffd62ab65b94246798867c42e61de208d5e /tools | |
parent | 10fc439940f5f2e8ab5053d1587b8bd256944492 (diff) | |
parent | 135fb07d959741dbe9a3a4e5e1919de0e7c5bc44 (diff) | |
download | vyos-build-a83e5139eda1d4f2cb77f9b06da42f84aa5d7fc0.tar.gz vyos-build-a83e5139eda1d4f2cb77f9b06da42f84aa5d7fc0.zip |
Merge branch 'current' of github.com:vyos/vyos-build into current
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/get_latest_iso.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/get_latest_iso.py b/tools/get_latest_iso.py new file mode 100755 index 00000000..4a2ea9a8 --- /dev/null +++ b/tools/get_latest_iso.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import os +import sys +from lxml import html +from urllib.parse import unquote +import requests + +BASE_URL = 'https://downloads.vyos.io/' +PAGE_URL = BASE_URL+'?dir=rolling/current/amd64' + + +def download(): + page = requests.get(PAGE_URL) + tree = html.fromstring(page.content) + path = '//*[@id="directory-listing"]/li/a[1]/@href' + isos = [x for x in tree.xpath(path) if os.path.splitext(x)[1] == '.iso'] + latest_iso_url = os.path.join(BASE_URL, isos[-1]) + filename = unquote(os.path.basename(latest_iso_url)) + print(filename) + if os.path.exists(filename): + print("{} already exists".format(filename)) + sys.exit(0) + r = requests.get(latest_iso_url) + with open(filename, 'wb') as fd: + for chunk in r.iter_content(chunk_size=128): + fd.write(chunk) + + +if __name__ == '__main__': + download() |