|
23 | 23 | """ |
24 | 24 |
|
25 | 25 | import os |
26 | | -from typing import BinaryIO, Dict, TextIO |
27 | 26 | from urllib import parse |
28 | 27 |
|
29 | 28 | from securesystemslib import exceptions as sslib_exceptions |
30 | 29 | from securesystemslib import formats as sslib_formats |
31 | 30 | from securesystemslib import util as sslib_util |
32 | 31 |
|
33 | | -from tuf import exceptions, formats |
34 | | -from tuf.client_rework import download |
| 32 | +from tuf import formats |
35 | 33 |
|
36 | 34 | # The type of file to be downloaded from a repository. The |
37 | 35 | # 'get_list_of_mirrors' function supports these file types. |
@@ -130,67 +128,3 @@ def get_list_of_mirrors(file_type, file_path, mirrors_dict): |
130 | 128 | list_of_mirrors.append(url.replace("\\", "/")) |
131 | 129 |
|
132 | 130 | return list_of_mirrors |
133 | | - |
134 | | - |
135 | | -def mirror_meta_download( |
136 | | - filename: str, |
137 | | - upper_length: int, |
138 | | - mirrors_config: Dict, |
139 | | - fetcher: "FetcherInterface", |
140 | | -) -> TextIO: |
141 | | - """ |
142 | | - Download metadata file from the list of metadata mirrors |
143 | | - """ |
144 | | - file_mirrors = get_list_of_mirrors("meta", filename, mirrors_config) |
145 | | - |
146 | | - file_mirror_errors = {} |
147 | | - for file_mirror in file_mirrors: |
148 | | - try: |
149 | | - temp_obj = download.download_file( |
150 | | - file_mirror, upper_length, fetcher, strict_required_length=False |
151 | | - ) |
152 | | - |
153 | | - temp_obj.seek(0) |
154 | | - yield temp_obj |
155 | | - |
156 | | - # pylint cannot figure out that we store the exceptions |
157 | | - # in a dictionary to raise them later so we disable |
158 | | - # the warning. This should be reviewed in the future still. |
159 | | - except Exception as exception: # pylint: disable=broad-except |
160 | | - file_mirror_errors[file_mirror] = exception |
161 | | - |
162 | | - finally: |
163 | | - if file_mirror_errors: |
164 | | - raise exceptions.NoWorkingMirrorError(file_mirror_errors) |
165 | | - |
166 | | - |
167 | | -def mirror_target_download( |
168 | | - fileinfo: str, mirrors_config: Dict, fetcher: "FetcherInterface" |
169 | | -) -> BinaryIO: |
170 | | - """ |
171 | | - Download target file from the list of target mirrors |
172 | | - """ |
173 | | - # full_filename = _get_full_name(filename) |
174 | | - file_mirrors = get_list_of_mirrors( |
175 | | - "target", fileinfo["filepath"], mirrors_config |
176 | | - ) |
177 | | - |
178 | | - file_mirror_errors = {} |
179 | | - for file_mirror in file_mirrors: |
180 | | - try: |
181 | | - temp_obj = download.download_file( |
182 | | - file_mirror, fileinfo["fileinfo"]["length"], fetcher |
183 | | - ) |
184 | | - |
185 | | - temp_obj.seek(0) |
186 | | - yield temp_obj |
187 | | - |
188 | | - # pylint cannot figure out that we store the exceptions |
189 | | - # in a dictionary to raise them later so we disable |
190 | | - # the warning. This should be reviewed in the future still. |
191 | | - except Exception as exception: # pylint: disable=broad-except |
192 | | - file_mirror_errors[file_mirror] = exception |
193 | | - |
194 | | - finally: |
195 | | - if file_mirror_errors: |
196 | | - raise exceptions.NoWorkingMirrorError(file_mirror_errors) |
0 commit comments