lava_rpc_connector: Dont swallow HTTP exceptions silently
This causes bad data to go into output files (e.g. HTTP error messages)
which then cause errors much later in processing pipeline. Let errors
happen where they happen (so we're able to analyze them and see how
to react to them).
Actually, add call to raise_for_status(), so HTTP protocol errors were
properly detected.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Change-Id: I72cffdcbd3baf1a636b8dbc4eac1bfdc987afcb1
diff --git a/tfm_ci_pylib/lava_rpc_connector.py b/tfm_ci_pylib/lava_rpc_connector.py
index e43eaf5..567f425 100644
--- a/tfm_ci_pylib/lava_rpc_connector.py
+++ b/tfm_ci_pylib/lava_rpc_connector.py
@@ -82,13 +82,11 @@
'user': self.username,
'token': self.token
}
- try:
- with requests.get(url, stream=True, params=auth_params) as r:
- with open(out_file, 'wb') as f:
- shutil.copyfileobj(r.raw, f)
- return(out_file)
- except:
- return(False)
+ with requests.get(url, stream=True, params=auth_params) as r:
+ r.raise_for_status()
+ with open(out_file, 'wb') as f:
+ shutil.copyfileobj(r.raw, f)
+ return(out_file)
def get_job_results(self, job_id, yaml_out_file):
results_url = "{}/yaml".format(self.server_results_prefix % job_id)
@@ -108,9 +106,7 @@
server_url=self.server_api, job_id=job_id
)
with requests.get(log_url, stream=True, headers=auth_headers) as r:
- if r.status_code != 200:
- print("{} - {}".format(log_url, r.status_code))
- return
+ r.raise_for_status()
log_list = yaml.load(r.content, Loader=yaml.SafeLoader)
with open(target_out_file, "w") as target_out:
for line in log_list: