[gbm-web] redirector: Drop boto3 and fetch latest-* files directly



commit 6fa004efa1272e703a7f2100f448a6d7ff21aa66
Author: Bartłomiej Piotrowski <bpiotrowski gnome org>
Date:   Thu Oct 29 14:20:41 2020 +0100

    redirector: Drop boto3 and fetch latest-* files directly

 redirector/main.py          | 8 +++-----
 redirector/requirements.txt | 5 ++++-
 2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/redirector/main.py b/redirector/main.py
index 98b81e5..4a87db5 100644
--- a/redirector/main.py
+++ b/redirector/main.py
@@ -1,6 +1,6 @@
 import os.path
 
-import boto3
+import requests
 from fastapi import FastAPI, Response, status
 from fastapi.responses import RedirectResponse
 from pydantic import BaseSettings
@@ -33,10 +33,8 @@ def get_nightly(filename: str):
     else:
         return Response(status_code=status.HTTP_404_NOT_FOUND)
 
-    s3 = boto3.resource('s3')
-    latest_file_key = f"nightly/{latest_filename}"
-    obj = s3.Object(cfg.bucket_name, latest_file_key)
-    latest = obj.get()['Body'].read().decode('utf-8').rstrip()
+    r = requests.get(f"{cfg.bucket_url}/nightly/{latest_filename}")
+    latest = r.text.rstrip()
 
     response = RedirectResponse(f"{cfg.bucket_url}/{latest}")
     response.status_code = status.HTTP_301_MOVED_PERMANENTLY
diff --git a/redirector/requirements.txt b/redirector/requirements.txt
index b3c9f3c..843d085 100644
--- a/redirector/requirements.txt
+++ b/redirector/requirements.txt
@@ -1,11 +1,14 @@
-boto3==1.16.6
 botocore==1.19.6
+certifi==2020.6.20
+chardet==3.0.4
 click==7.1.2
 fastapi==0.61.1
 h11==0.11.0
+idna==2.10
 jmespath==0.10.0
 pydantic==1.7
 python-dateutil==2.8.1
+requests==2.24.0
 s3transfer==0.3.3
 six==1.15.0
 starlette==0.13.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]