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

Commit

Permalink
squad-download-attachments: save to a csv file
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Roxell <[email protected]>
  • Loading branch information
roxell committed Dec 22, 2023
1 parent 6ec4fbe commit a6892e2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,14 @@ They will be stored in a directory 'stored_attachments/<environment>'_'<testrun_

```
./squad-download-attachments --help
usage: squad-download-attachments [-h] --group GROUP --project PROJECT --build BUILD_ID
usage: squad-download-attachments [-h] --group GROUP --project PROJECT --build BUILD_ID [--csv]
options:
-h, --help show this help message and exit
--group GROUP The name of the SQUAD group.
--project PROJECT The name of the SQUAD project.
--build BUILD SQUAD build id.
--csv Create csv files.
```

### `read-skipfile-results`: Read results from
Expand Down
37 changes: 37 additions & 0 deletions squad-download-attachments
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
# SPDX-License-Identifier: MIT

import argparse
import csv
import json
import logging
from os import chdir
from pathlib import Path
import statistics
import sys
from squad_client.core.api import SquadApi
from squad_client.core.models import ALL, Squad, TestRun, Environment
Expand Down Expand Up @@ -47,6 +49,14 @@ def arg_parser():
help="squad build",
)

parser.add_argument(
"--csv",
default=False,
action="store_true",
required=False,
help="generate csv files",
)

return parser


Expand Down Expand Up @@ -109,6 +119,33 @@ def run():
with open(file_write, mode="w") as write_file:
write_file.write(pjson)

if not args.csv:
continue

with open(file_write.replace(".json", ".csv"), mode="w") as csv_file:
csv_writer = csv.writer(csv_file)
dict_json = json.loads(pjson)
if not dict_json["results"]:
continue
headers = ["median", "mean", "standard diviation", "name", "iteration", "name_iteration", "raw data..."]
csv_writer.writerow(headers)
for key in dict_json["results"]["_ResultData"]:
iterations = 0
for k in dict_json["results"]["_ResultData"][key]:
csv_data = []
float_arr = []
for number in k["Values"]:
float_arr.append(float(number))
csv_data.append(statistics.median(float_arr))
csv_data.append(statistics.mean(float_arr))
csv_data.append(statistics.stdev(float_arr))
csv_data.append(key)
iterations = iterations + 1
csv_data.append(f"iteration_{iterations}")
csv_data.append(f"{key}_iterattion_{iterations}")
csv_data.extend(k['Values'])
csv_writer.writerow(csv_data)


if __name__ == "__main__":
sys.exit(run())

0 comments on commit a6892e2

Please sign in to comment.