generated from HenriqueAmorim20/GEROcuidadoAPITemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
/
parser.py
42 lines (33 loc) · 967 Bytes
/
parser.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
37
38
39
40
41
42
import json
import requests
import sys
from datetime import datetime
import pytz
desired_timezone = pytz.timezone('America/Sao_Paulo')
TODAY = datetime.now(desired_timezone)
METRICS_SONAR = [
"files",
"functions",
"complexity",
"comment_lines_density",
"duplicated_lines_density",
"coverage",
"ncloc",
"tests",
"test_errors",
"test_failures",
"test_execution_time",
"security_rating",
]
BASE_URL = "https://sonarcloud.io/api/measures/component_tree?component=fga-eps-mds_"
if __name__ == "__main__":
REPO = sys.argv[1]
RELEASE_VERSION = sys.argv[2]
response = requests.get(
f'{BASE_URL}{REPO}&metricKeys={",".join(METRICS_SONAR)}&ps=500'
)
j = json.loads(response.text)
file_path = f'./analytics-raw-data/fga-eps-mds-{REPO}-{TODAY.strftime("%m-%d-%Y-%H-%M-%S")}-{RELEASE_VERSION}.json'
with open(file_path, "w") as fp:
fp.write(json.dumps(j))
fp.close()