forked from fga-eps-mds/2024-1-GEROcuidado-Front
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.py
43 lines (34 loc) · 1018 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
43
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="
if __name__ == "__main__":
REPO_COMPONENT_KEY = sys.argv[1]
REPO = sys.argv[2]
RELEASE_VERSION = sys.argv[3].replace('/', '')
response = requests.get(
f'{BASE_URL}{REPO_COMPONENT_KEY}&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()