Handle case when url returns 404 or not XML
Also extended .gitignore
RelatedProd: PRODX-48948
Change-Id: I763406085664cae23098b112bb6e340a2ce8b888
diff --git a/.gitignore b/.gitignore
index 8d00c83..e8179bc 100755
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,7 @@
oscore-e717344565a0.json
*.json
*.log
-venv/
\ No newline at end of file
+venv/
+*/*.egg-info/*
+.*
+*/build/*
\ No newline at end of file
diff --git a/rp_reporter/rp_reporter/batch_reporter.py b/rp_reporter/rp_reporter/batch_reporter.py
index 7a906c6..0ee2664 100755
--- a/rp_reporter/rp_reporter/batch_reporter.py
+++ b/rp_reporter/rp_reporter/batch_reporter.py
@@ -13,7 +13,7 @@
import logging
logging.basicConfig(level=logging.DEBUG)
-LOG = logging.getLogger(__name__)
+LOG = logging.getLogger("rp_reporter")
def upload_job(job:str, suite_per_job=False, tags=None):
if isinstance(job, str):
diff --git a/rp_reporter/rp_reporter/report_from_xml.py b/rp_reporter/rp_reporter/report_from_xml.py
index 37fbc06..f0a5429 100644
--- a/rp_reporter/rp_reporter/report_from_xml.py
+++ b/rp_reporter/rp_reporter/report_from_xml.py
@@ -1,6 +1,7 @@
import os
import click
import ipdb
+import urllib
import xunitparser
import logging
import pathlib
@@ -14,7 +15,7 @@
from .settings import RP_ENDPOINT, RP_APIKEY, RP_PROJECT
-LOG = logging.getLogger(__name__)
+LOG = logging.getLogger("rp_reporter")
scheduled = []
uuid_by_subfolder = dict()
@@ -74,7 +75,14 @@
scheduled = list()
_report_path = str(report_path)
if report_path.startswith("http"):
- report_path = wget.download(report_path, f"/tmp/")
+ try:
+ report_path = wget.download(report_path, f"/tmp/")
+ except urllib.error.HTTPError:
+ print("File is absent")
+ return
+ if not open(report_path).read().startswith("<xml"):
+ print("File is absent or not in XML format")
+ return
if pathlib.Path(report_path).exists():
report_file = report_path
else:
diff --git a/rp_reporter/rp_reporter/settings.py b/rp_reporter/rp_reporter/settings.py
index 63132aa..773e6bc 100644
--- a/rp_reporter/rp_reporter/settings.py
+++ b/rp_reporter/rp_reporter/settings.py
@@ -4,7 +4,7 @@
import logging
-LOG = logging.getLogger(__name__)
+LOG = logging.getLogger("rp_reporter")
RP_CONFIG_FILE = environ.get("RP_CONFIG_FILE") or (Path.home() / ".reportportal_config")