-
Notifications
You must be signed in to change notification settings - Fork 1
/
gha_disk_image_scanner.py
36 lines (32 loc) · 1.12 KB
/
gha_disk_image_scanner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
import subprocess as sp
import click
import json
@click.command()
@click.argument("json-file-path")
@click.argument("image-key")
@click.argument("table-path")
def scan_image(
json_file_path: str,
image_key: str,
table_path: str,
):
"""Scans disk image in GitHub Actions (runs-on: ubuntu).
Takes the path to the json-file, key of the image in it, and the path to the table to save."""
with open(json_file_path, "r") as read_file:
image_info = json.load(read_file)["disk-images"]
url, objdump_package, objdump_command = None, None, None
for item in image_info:
if item["key"] == image_key:
url = item["url"]
objdump_package = item["objdump-package"]
objdump_command = item["objdump-command"]
if url is None:
raise KeyError("No such key.")
sp.run(["sudo", "apt-get", "install", "--yes", objdump_package], capture_output=False)
sp.run(
["./data_collection/disk_image_data_collection.sh", "-u", "-o", objdump_command, url, table_path],
capture_output=False,
)
if __name__ == "__main__":
scan_image()