summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorentin LABBE <clabbe@baylibre.com>2021-03-23 08:31:35 +0000
committerCorentin LABBE <clabbe@baylibre.com>2021-03-23 08:31:35 +0000
commit003acac3ec67492eace409a6d281829185a9129d (patch)
tree5a0f11eed199170cbf711354547793f8817504a9
parente77bec194555ab2f73bf5370d38d7565bc868b52 (diff)
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 <clabbe@baylibre.com>
-rwxr-xr-xutils/agl-publish.py26
1 files 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',