|
22 | 22 | Exports SonarQube platform configuration as JSON |
23 | 23 | """ |
24 | 24 | import sys |
25 | | -import os |
26 | | -from threading import Lock |
27 | 25 |
|
28 | 26 | from cli import options |
29 | 27 | from sonar import exceptions, errcodes, utilities, version |
|
67 | 65 | options.WHAT_PORTFOLIOS: __JSON_KEY_PORTFOLIOS, |
68 | 66 | } |
69 | 67 |
|
70 | | -_WRITE_LOCK = Lock() |
71 | 68 |
|
72 | 69 | def __parse_args(desc): |
73 | 70 | parser = options.set_common_args(desc) |
@@ -102,36 +99,6 @@ def __write_export(config: dict[str, str], file: str) -> None: |
102 | 99 | print(utilities.json_dump(config), file=fd) |
103 | 100 |
|
104 | 101 |
|
105 | | -def __remove_chars_at_end(file: str, nb_bytes: int) -> None: |
106 | | - """Writes the configuration in file""" |
107 | | - with open(file, mode="rb+") as fd: |
108 | | - fd.seek(-nb_bytes, os.SEEK_END) |
109 | | - fd.truncate() |
110 | | - |
111 | | - |
112 | | -def __add_project_header(file: str) -> None: |
113 | | - """Writes the configuration in file""" |
114 | | - with open(file, mode="a", encoding="utf-8") as fd: |
115 | | - print(',\n "projects": {\n', file=fd) |
116 | | - |
117 | | - |
118 | | -def __add_project_footer(file: str) -> None: |
119 | | - """Closes projects section""" |
120 | | - __remove_chars_at_end(file, 2) |
121 | | - with open(file, mode="a", encoding="utf-8") as fd: |
122 | | - print("\n }\n}", file=fd) |
123 | | - |
124 | | - |
125 | | -def write_project(project_json: dict[str, any], file: str) -> None: |
126 | | - """ |
127 | | - writes a project JSON in a file |
128 | | - """ |
129 | | - key = project_json.pop("key") |
130 | | - with _WRITE_LOCK: |
131 | | - with utilities.open_file(file, mode="a") as fd: |
132 | | - print(f'"{key}": {utilities.json_dump(project_json)},', file=fd) |
133 | | - |
134 | | - |
135 | 102 | def __export_config(endpoint: platform.Platform, what: list[str], **kwargs) -> None: |
136 | 103 | """Exports a platform configuration in a JSON file""" |
137 | 104 | export_settings = { |
@@ -171,7 +138,6 @@ def __export_config(endpoint: platform.Platform, what: list[str], **kwargs) -> N |
171 | 138 | ndx, func = call_data |
172 | 139 | try: |
173 | 140 | sq_settings[ndx] = func(endpoint, export_settings=export_settings, key_list=key_list) |
174 | | - __write_export(sq_settings, kwargs[options.REPORT_FILE]) |
175 | 141 | except exceptions.UnsupportedOperation as e: |
176 | 142 | log.warning(e.message) |
177 | 143 | sq_settings = utilities.remove_empties(sq_settings) |
|
0 commit comments