Skip to content
Merged
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
25 changes: 18 additions & 7 deletions framework/python/src/test_orc/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,37 +271,48 @@ def zip_results(self,
device.device_folder),
timestamp)

# Define temp directory to store files before zipping
results_dir = os.path.join(f'/tmp/testrun/{time.time()}')

# Define where to save the zip file
zip_location = os.path.join('/tmp/testrun',timestamp)
zip_location = os.path.join("/tmp/testrun",
timestamp)

# Delete zip_temp if it already exists
if os.path.exists(results_dir):
os.remove(results_dir)

# Delete ZIP if it already exists
if os.path.exists(zip_location + ".zip"):
os.remove(zip_location + ".zip")

shutil.copytree(src_path,results_dir)

# Include profile if specified
if profile is not None:
LOGGER.debug(
f"Copying profile {profile.name} to results directory")
shutil.copy(profile.get_file_path(),
os.path.join(
src_path,
results_dir,
"profile.json"))

with open(os.path.join(src_path, "profile.pdf"), "wb") as f:
with open(os.path.join(results_dir, "profile.pdf"), "wb") as f:
f.write(profile.to_pdf(device).getvalue())

with open(os.path.join(src_path, "profile.html"), "w") as fp:
fp.write(profile.to_html(device))

# Create ZIP archive
shutil.make_archive(zip_location, "zip", src_path)
shutil.make_archive(zip_location, "zip", results_dir)

# Delete the temp results directory
shutil.rmtree(results_dir)

# Check that the ZIP was successfully created
zip_file = zip_location + ".zip"
LOGGER.info(f'''Archive {'created at ' + zip_file
if os.path.exists(zip_file)
else'creation failed'}''')


return zip_file

except Exception as error: # pylint: disable=W0703
Expand Down