Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

[1LP][RFR] fixing one more issue in artifactor's filedump #9755

Merged
merged 4 commits into from
Dec 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions artifactor/plugins/filedump.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,18 @@ def filedump(
if not slaveid:
slaveid = "Master"
if slaveid not in self.store:
self.store[slaveid] = {}
self.store[slaveid] = {
"test_location": test_location or "",
"test_name": test_name or "",
}
test_ident = "{}/{}".format(
self.store[slaveid]["test_location"], self.store[slaveid]["test_name"]
)
artifacts = []
if os_filename is None:
safe_name = re.sub(r"\s+", "_", normalize_text(safe_string(description)))
os_filename = self.ident + "-" + safe_name
os_filename = os.path.join(self.store[slaveid]["artifact_path"], os_filename)
os_filename = os.path.join(self.store[slaveid].get("artifact_path", ""), os_filename)
if file_type is not None and "screenshot" in file_type:
os_filename = os_filename + ".png"
elif file_type is not None and (
Expand All @@ -96,9 +99,11 @@ def filedump(
if not dont_write:
if os.path.isfile(os_filename):
os.remove(os_filename)
if contents_base64:
contents = base64.b64decode(contents)
if isinstance(contents, bytes):
mode = "wb"
with open(os_filename, mode) as f:
if contents_base64:
contents = base64.b64decode(contents)
f.write(contents)

return None, {"artifacts": {test_ident: {"files": artifacts}}}
Expand Down
4 changes: 2 additions & 2 deletions artifactor/plugins/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def build_li(self, lev):

# If 'name' is an attribute then we are looking at a test (leaf).
if "name" in v:
pretty_time = str(datetime.timedelta(seconds=math.ceil(v["duration"])))
pretty_time = str(datetime.timedelta(seconds=math.ceil(v.get("duration", 0))))
teststring = '<span name="mod_lev" class="label label-primary">T</span>'
label = '<span class="label label-{}">{}</span>'.format(
bimdict[v["outcomes"]["overall"]], v["outcomes"]["overall"].upper()
Expand Down Expand Up @@ -319,7 +319,7 @@ def build_li(self, lev):
bimdict[level], percen
)
modstring = '<span name="mod_lev" class="label label-primary">M</span>'
pretty_time = str(datetime.timedelta(seconds=math.ceil(v["_duration"])))
pretty_time = str(datetime.timedelta(seconds=math.ceil(v.get("_duration", 0))))
list_string += (
"<li>{} {}<span>&nbsp;</span>"
'{}{}<span style="color:#888888">&nbsp;<em>[{}]'
Expand Down