Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

add squad-download-attachments #36

Merged
merged 1 commit into from
Dec 21, 2023
Merged

Conversation

roxell
Copy link
Collaborator

@roxell roxell commented Dec 13, 2023

No description provided.

@roxell roxell force-pushed the download-attachments branch 7 times, most recently from 17a44d7 to 64d5f53 Compare December 18, 2023 12:36
@katieworton
Copy link
Member

@roxell Looks like things are ready for review so I will have a look through this and add some comments shortly :)

@roxell roxell force-pushed the download-attachments branch from 64d5f53 to 8dfdd75 Compare December 18, 2023 14:19
Copy link
Member

@katieworton katieworton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me - just added a few comments where I think there should be more documentation.

Path.mkdir(dirname, parents=True, exist_ok=True)
chdir(dirname)
download_attachments(TestRun(testrun))
chdir(sys.path[0])
Copy link
Member

@katieworton katieworton Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume changing to sys.path[0] means the script won't work properly if launched from a different directory (so it would only work correctly if the user launches from squad-client-utils). I think that's fine for this case, but it should probably be documented.

env_name = Environment(getid((TestRun(testrun).environment))).slug
dirname = Path(f"{attachment_dir}/{env_name}_{str(TestRun(testrun).id)}")
print(dirname)
if "qemu-" in dirname.name:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to add a comment here to say why we only want "qemu-" - it will make it easier to understand the purpose of the script.

chdir(sys.path[0])

file = glob.glob(f"{dirname}/mmtests-*.tar.xz")
with contextlib.closing(lzma.LZMAFile(file[0])) as xz:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to comment what is being extracted and why


file = glob.glob(f"{dirname}/output/*.json")
file_write = file[0].replace("/output", "")
with open(file[0], mode="r") as read_file:
Copy link
Member

@katieworton katieworton Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment to say what this step does and its purpose (looks like it finds the json file - presumably there is only one of these since we are referencing file[0] - and then it removes "/output" and sorts the json keys)

@roxell roxell force-pushed the download-attachments branch 2 times, most recently from 8bbb5dd to 3cee2e0 Compare December 21, 2023 12:10
This scripts helps with downloading all attachments from SQUAD for a
given group, project and build_id.

For now the attachments only works in tuxsuite/tuxrun.

Signed-off-by: Anders Roxell <[email protected]>
@roxell roxell force-pushed the download-attachments branch from 3cee2e0 to fbc4293 Compare December 21, 2023 12:41
@roxell roxell merged commit 6ec4fbe into Linaro:master Dec 21, 2023
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants