forked from fga-eps-mds/2021.2-SysArq-Frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.py
37 lines (29 loc) · 865 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
import json
import requests
import sys
from datetime import datetime
TODAY = datetime.now()
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()