Skip to content
Snippets Groups Projects
Commit b3d0f962 authored by Jedrzej Rybicki's avatar Jedrzej Rybicki
Browse files

urllib fix

parent dcec1a4d
No related branches found
No related tags found
No related merge requests found
Pipeline #76954 passed
......@@ -3,6 +3,7 @@ from airflow.models.connection import Connection
import requests
from urllib.parse import urljoin
import tempfile
import urllib
def get_objects(server):
lst = requests.get(urljoin(server, 'api/records')).json()
......@@ -19,7 +20,8 @@ def get_object_md(server, oid):
return obj
def download_file(url: str, target_dir: str):
_, fname = tempfile.mkstemp(dir=target_dir)
fname = tempfile.mkstemp(dir=target_dir)
urllib.request.urlretrieve(url=url, filename=fname)
return fname
......
......@@ -30,7 +30,7 @@ def taskflow_example():
name_mappings = {}
for fname, url in flist.items():
print(f"Processing: {fname} --> {url}")
tmpname = download_file(url=url, target_dir='/tmp/downs/')
tmpname = download_file(url=url, target_dir='/tmp/')
name_mappings[fname]=tmpname
return name_mappings
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment