Skip to content

Commit

Permalink
Fix download
Browse files Browse the repository at this point in the history
  • Loading branch information
meteoDaniel authored and meteoDaniel committed Jun 16, 2020
1 parent 408a039 commit 7a30358
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions python_dwd/constants/access_credentials.py
Expand Up @@ -4,6 +4,7 @@
DWD_USER = 'anonymous'
DWD_PASSWORD = ''
FTP_EXPRESSION = 'ftp://'
HTTPS_EXPRESSION = 'https://'

DWD_FOLDER_MAIN = './dwd_data'
DWD_FOLDER_METADATA = 'metadata'
Expand Down
8 changes: 4 additions & 4 deletions python_dwd/download/download.py
Expand Up @@ -52,10 +52,10 @@ def _download_dwd_data(remote_file: Union[str, Path]) -> BytesIO:
try:
with urllib.request.urlopen(file_server) as url_request:
zip_file = BytesIO(url_request.read())
except urllib.error.URLError:
raise urllib.error.URLError(f"Error: the stationdata {file_server} couldn't be reached.")
except urllib.error.HTTPError:
pass
except urllib.error.URLError as e:
raise e(f"Error: the stationdata {file_server} couldn't be reached.")
except:
print(file_server)

try:
with zipfile.ZipFile(zip_file) as zip_file_opened:
Expand Down
4 changes: 2 additions & 2 deletions python_dwd/download/download_services.py
Expand Up @@ -2,7 +2,7 @@
from pathlib import Path, PurePosixPath
from typing import Union

from python_dwd.constants.access_credentials import DWD_FOLDER_STATIONDATA, DWD_SERVER, DWD_PATH, FTP_EXPRESSION
from python_dwd.constants.access_credentials import DWD_FOLDER_STATIONDATA, DWD_SERVER, DWD_PATH, HTTPS_EXPRESSION


def create_local_file_name(remote_file_path: Union[Path, str],
Expand Down Expand Up @@ -32,4 +32,4 @@ def create_remote_file_name(file: str) -> str:
DWD_PATH,
file)

return f"{FTP_EXPRESSION}{file_server}"
return f"{HTTPS_EXPRESSION}{file_server}"

0 comments on commit 7a30358

Please sign in to comment.