|
7 | 7 |
|
8 | 8 | import os |
9 | 9 | import ftplib |
| 10 | +import requests |
10 | 11 | from datetime import datetime, timezone |
11 | 12 |
|
12 | 13 | import pytest |
@@ -247,8 +248,48 @@ def test_download_ephem(ephem_download_path, fileinfo): |
247 | 248 | dest_filepath = os.path.join(ephem_man.data_directory, 'nasa', filename) |
248 | 249 |
|
249 | 250 | # download the ephemeris file |
250 | | - ephem_man.retrieve_file(url, directory, filename, |
251 | | - dest_filepath) |
| 251 | + try: |
| 252 | + ephem_man.retrieve_file(url, directory, filename, |
| 253 | + dest_filepath) |
| 254 | + except ftplib.error_perm as ftplib_exception: |
| 255 | + print(ftplib_exception) |
| 256 | + |
| 257 | + remove_download_eph(ephem_download_path) |
| 258 | + |
| 259 | +@pytest.mark.parametrize('fileinfo', |
| 260 | + [ |
| 261 | + {'filepath': 'IGS/BRDC/2023/099/BRDC00WRD_S_20230990000_01D_MN.rnx.gz', |
| 262 | + 'url': 'http://igs.bkg.bund.de/root_ftp/'}, |
| 263 | + ]) |
| 264 | +def test_request_igs(ephem_download_path, fileinfo): |
| 265 | + """Test requests download for igs files. |
| 266 | +
|
| 267 | + The reason for this test is that Github workflow actions seem to |
| 268 | + block international IPs and so won't properly bind to the igs IP. |
| 269 | +
|
| 270 | + Parameters |
| 271 | + ---------- |
| 272 | + ephem_download_path : string |
| 273 | + Location where ephemeris files are stored/to be downloaded to. |
| 274 | + fileinfo : dict |
| 275 | + Filenames for ephemeris with ftp server and constellation details |
| 276 | +
|
| 277 | + """ |
| 278 | + |
| 279 | + remove_download_eph(ephem_download_path) |
| 280 | + os.makedirs(ephem_download_path) |
| 281 | + |
| 282 | + ephem_man = EphemerisManager(ephem_download_path, verbose=True) |
| 283 | + |
| 284 | + filepath = fileinfo['filepath'] |
| 285 | + filename = os.path.split(filepath)[1] |
| 286 | + dest_filepath = os.path.join(ephem_man.data_directory, 'igs', filename) |
| 287 | + |
| 288 | + requests_url = fileinfo['url'] + fileinfo['filepath'] |
| 289 | + |
| 290 | + response = requests.get(requests_url, timeout=5) |
| 291 | + with open(dest_filepath,'wb') as file: |
| 292 | + file.write(response.content) |
252 | 293 |
|
253 | 294 | remove_download_eph(ephem_download_path) |
254 | 295 |
|
|
0 commit comments