From 003acac3ec67492eace409a6d281829185a9129d Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Tue, 23 Mar 2021 08:31:35 +0000 Subject: SPEC-3414: Permit to use the bmeta helper without token Allow to use utils/agl-publish.py without token for debugging and verifying it works. Change-Id: I2d752d3debf25ab1bb78fdd39c45bbd79ab1aedd Bug-AGL: SPEC-3414 Signed-off-by: Corentin LABBE --- utils/agl-publish.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/utils/agl-publish.py b/utils/agl-publish.py index a6b540b..b559566 100755 --- a/utils/agl-publish.py +++ b/utils/agl-publish.py @@ -7,8 +7,16 @@ import os import json import urllib -ptoken=os.environ["KCI_PUSH_TOKEN"] -utoken=os.environ["KCI_UPLOAD_TOKEN"] +if not "KCI_PUSH_TOKEN" in os.environ: + print("Missing env variable KCI_PUSH_TOKEN") + ptoken=None +else: + ptoken=os.environ["KCI_PUSH_TOKEN"] +if not "KCI_UPLOAD_TOKEN" in os.environ: + print("Missing env variable KCI_UPLOAD_TOKEN") + utoken=None +else: + utoken=os.environ["KCI_UPLOAD_TOKEN"] parser = argparse.ArgumentParser(description="AGL create bmeta", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--arch', action='store', help="arch of the build", required=True) @@ -48,9 +56,6 @@ with open(os.path.join(DIR_META, 'bmeta.json'), 'w') as json_file: def upload(): path = bmeta["file_server_resource"] - headers = { - 'Authorization': utoken, - } data = { 'path': path, } @@ -67,7 +72,12 @@ def upload(): url = urljoin(args.api, 'upload') print("DATA====================") print(data) - return 0 + if utoken is None: + print("No upload token, skipping upload") + return 0 + headers = { + 'Authorization': utoken, + } resp = requests.post(url, headers=headers, data=data, files=files) resp.raise_for_status() print(resp.reason) @@ -87,7 +97,9 @@ def publish_kernel(): }.items()} print("DATA====================") print(data) - return 0 + if ptoken is None: + print("No publish token, skipping publish") + return 0 headers = { 'Authorization': ptoken, 'Content-Type': 'application/json', -- cgit 1.2.3-korg