From dd1525c9b75df5f969681907979abd001be49ae8 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 30 Apr 2019 12:27:08 -0700 Subject: [PATCH 1/5] First version of BackTrace upload python script. --- hifi_backtrace_post.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 hifi_backtrace_post.py diff --git a/hifi_backtrace_post.py b/hifi_backtrace_post.py new file mode 100644 index 0000000000..7df9b867a2 --- /dev/null +++ b/hifi_backtrace_post.py @@ -0,0 +1,18 @@ +# Parameters: +# 1 - $BACKTRACE_UPLOAD_TOKEN +# 2 - $SYMBOLS_ARCHIVE +# 3 - $RELEASE_NUMBER +# +import sys +import urllib.request +import urllib.parse + +post_headers = {} +post_headers['Content-Type'] = 'application/json' +post_headers['Expect'] = '' + +post_url = 'https://highfidelity.sp.backtrace.io:6098/post?format=symbols&token=' + sys.argv[1] + '&upload_file=' + sys.argv[2] + '&tag=' + sys.argv[3] +post_data = open(sys.argv[1], 'rb') + +post_request = urllib.request.Request(post_url, post_data, post_headers) +post_response = urllib.request.urlopen(post_request) From 125d182773dcd1c8414d789f18038152f9d95b7f Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 30 Apr 2019 14:09:16 -0700 Subject: [PATCH 2/5] Added try/except blocks. --- hifi_backtrace_post.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/hifi_backtrace_post.py b/hifi_backtrace_post.py index 7df9b867a2..96dcee5c8f 100644 --- a/hifi_backtrace_post.py +++ b/hifi_backtrace_post.py @@ -12,7 +12,23 @@ post_headers['Content-Type'] = 'application/json' post_headers['Expect'] = '' post_url = 'https://highfidelity.sp.backtrace.io:6098/post?format=symbols&token=' + sys.argv[1] + '&upload_file=' + sys.argv[2] + '&tag=' + sys.argv[3] -post_data = open(sys.argv[1], 'rb') -post_request = urllib.request.Request(post_url, post_data, post_headers) -post_response = urllib.request.urlopen(post_request) +try: + post_data = open(sys.argv[2], 'rb') +except: + print('file ' + sys.argv[2] + ' not found') + exit() + +try: + post_request = urllib.request.Request(post_url, post_data, post_headers) +except: + print('urllib.request.Request failed') + exit() + +try: + post_response = urllib.request.urlopen(post_request) +except: + print('urllib.request.urlopen failed') + exit() + +print("No errors") \ No newline at end of file From 867f1f80df94aae71fe678b167653f37b4e3c7ef Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Tue, 30 Apr 2019 15:26:39 -0700 Subject: [PATCH 3/5] Improved messages. --- hifi_backtrace_post.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hifi_backtrace_post.py b/hifi_backtrace_post.py index 96dcee5c8f..b55e72fde9 100644 --- a/hifi_backtrace_post.py +++ b/hifi_backtrace_post.py @@ -7,6 +7,8 @@ import sys import urllib.request import urllib.parse +print("Running python script to upload to BackTrace") + post_headers = {} post_headers['Content-Type'] = 'application/json' post_headers['Expect'] = '' @@ -18,7 +20,7 @@ try: except: print('file ' + sys.argv[2] + ' not found') exit() - + try: post_request = urllib.request.Request(post_url, post_data, post_headers) except: @@ -31,4 +33,4 @@ except: print('urllib.request.urlopen failed') exit() -print("No errors") \ No newline at end of file +print("Upload to BackTrace completed without errors") \ No newline at end of file From b9e2174fe9e3c2e4a7fc682a74d20f65fb4eb43d Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 1 May 2019 10:10:28 -0700 Subject: [PATCH 4/5] Use exit(1) on errors --- hifi_backtrace_post.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hifi_backtrace_post.py b/hifi_backtrace_post.py index b55e72fde9..a6871ef535 100644 --- a/hifi_backtrace_post.py +++ b/hifi_backtrace_post.py @@ -19,18 +19,18 @@ try: post_data = open(sys.argv[2], 'rb') except: print('file ' + sys.argv[2] + ' not found') - exit() + exit(1) try: post_request = urllib.request.Request(post_url, post_data, post_headers) except: print('urllib.request.Request failed') - exit() + exit(1) try: post_response = urllib.request.urlopen(post_request) except: print('urllib.request.urlopen failed') - exit() + exit(1) print("Upload to BackTrace completed without errors") \ No newline at end of file From 9dfcb675ca36b270efd7917e5ebee7ba257161a7 Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Wed, 1 May 2019 10:47:40 -0700 Subject: [PATCH 5/5] Moved script. --- hifi_backtrace_post.py => tools/ci-scripts/hifi_backtrace_post.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename hifi_backtrace_post.py => tools/ci-scripts/hifi_backtrace_post.py (100%) diff --git a/hifi_backtrace_post.py b/tools/ci-scripts/hifi_backtrace_post.py similarity index 100% rename from hifi_backtrace_post.py rename to tools/ci-scripts/hifi_backtrace_post.py