[rp-reporter]Handle non-XML formats properly
Related-Prod: PRODX-48948
Change-Id: I39dd55b3d3950b12f5f226eab055dcac0ad17e7a
diff --git a/rp_reporter/rp_reporter/report_from_xml.py b/rp_reporter/rp_reporter/report_from_xml.py
index f0a5429..75bc891 100644
--- a/rp_reporter/rp_reporter/report_from_xml.py
+++ b/rp_reporter/rp_reporter/report_from_xml.py
@@ -9,6 +9,7 @@
import re
import wget
import time
+from xml.etree import ElementTree
from reportportal_client import RPClient
from reportportal_client.helpers import timestamp
@@ -80,8 +81,10 @@
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")
+ try:
+ ElementTree.fromstring(open(report_path).read())
+ except ElementTree.ParseError:
+ print("File is not in XML format")
return
if pathlib.Path(report_path).exists():
report_file = report_path