summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2021-01-15 13:57:44 +0700
committerDaniil Baturin <daniil@baturin.org>2021-01-15 13:57:44 +0700
commit495bde0c30c3be39183ed9c9bc8e3e28a055abcb (patch)
treebe65040d06097a6082e2bd8011f8892e652d186e /scripts
parentf84bd975cedc9a3580d48a523da82a8aa47c46e4 (diff)
downloadcommunity.vyos.net-495bde0c30c3be39183ed9c9bc8e3e28a055abcb.tar.gz
community.vyos.net-495bde0c30c3be39183ed9c9bc8e3e28a055abcb.zip
Fix link format bugs in the snapshot list generator.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/list-snapshots.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/scripts/list-snapshots.py b/scripts/list-snapshots.py
index 1aab86f..d4bb9e4 100755
--- a/scripts/list-snapshots.py
+++ b/scripts/list-snapshots.py
@@ -17,7 +17,7 @@ bucket = os.getenv("SNAPSHOTS_BUCKET")
def make_link(s, f):
f = re.sub(r'\s+', '+', f)
- return "https://s3.amazonaws.com/{0}/snapshot/{1}/{2}".format(bucket, s, f)
+ return "https://s3.amazonaws.com/{0}/{1}".format(bucket, f)
s3 = boto3.client('s3')
object_listing = s3.list_objects_v2(Bucket=bucket, Prefix='snapshot')
@@ -38,14 +38,15 @@ for name in snapshot_names:
snapshot['files'] = list(filter(lambda s: re.search(name, s), files))
snapshot_files = list(filter(lambda s: re.search(name, s), files))
- snapshot_files = list(map(lambda f: {'name': os.path.basename(f), 'platform': os.path.basename(os.path.dirname(f)), 'link': make_link(name, f)}, snapshot_files))
+ snapshot_files = list(map(lambda f: {'name': os.path.basename(f).strip(), 'platform': os.path.basename(os.path.dirname(f)), 'link': make_link(name, f)}, snapshot_files))
+
+ # S3 listing sometimes returns dir names among file names... filter those out.
+ snapshot_files = list(filter(lambda f: f['name'] != "", snapshot_files))
snapshot['files'] = snapshot_files
snapshots.append(snapshot)
-#print(json.dumps(snapshots, indent=4))
-
tmpl = jinja2.Template("""
{% for s in snapshots %}
<h3>{{s.name}}</h3>