Skip to content

[2024-07-01 12:48] Fix for issue with AROME repository #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "weather_provider_api"
version = "2.53.0"
version = "2.54.0"
description = "Weather Provider Libraries and API"
authors = ["Verbindingsteam", "Raoul Linnenbank <58594297+rflinnenbank@users.noreply.github.com>"]
license = "MPL-2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# SPDX-FileCopyrightText: 2019-2022 Alliander N.V.
# SPDX-License-Identifier: MPL-2.0
import glob
import os
import re
import sys
import tarfile
Expand Down Expand Up @@ -178,7 +179,8 @@ def _process_downloaded_file(self, download_folder: Path, filename: str, predict
def _clear_temp_folder(download_folder: Path):
"""A function that cleans up the temporary download folder to prevent issues with partially written files."""
logger.debug(f"Emptying the download folder: {download_folder}")
for existing_file in glob.glob(f"{download_folder}*.*"):
file_filter = f"{download_folder}/*.*" if str(download_folder)[-1] != "/" else f"{download_folder}*.*"
for existing_file in glob.glob(file_filter):
try:
# Try to delete:
Path(existing_file).unlink()
Expand All @@ -191,9 +193,13 @@ def _unpack_downloaded_file(download_folder: Path, file_name: str):
"""The function that unpacks downloaded files to prediction files."""
logger.info(f"Unpacking file: {file_name}")
try:
tar_file = tarfile.open(download_folder.joinpath(file_name))
tar_file.extractall(path=download_folder)
tar_file.close()
tar = tarfile.open(download_folder.joinpath(file_name))
for member in tar.getmembers():
if member.isreg(): # Only process files
member.name = os.path.basename(
member.name) # Remove the path to setting it to only the filename.
tar.extract(member, download_folder) # Extract the file to the download folder
tar.close()
except Exception as e:
logger.error(f"The tarfile [{file_name}] could not be unpacked!")
raise e
Expand Down
Loading