|
10 | 10 |
|
11 | 11 | import requests |
12 | 12 | from requests_toolbelt.multipart.encoder import MultipartEncoder |
13 | | -import pycurl |
14 | | -import certifi |
15 | 13 | from urllib3.filepost import encode_multipart_formdata |
16 | 14 |
|
17 | 15 | from pyclowder.datasets import get_file_list |
@@ -46,26 +44,15 @@ def download(connector, host, key, fileid, intermediatefileid=None, ext=""): |
46 | 44 | intermediatefileid = fileid |
47 | 45 |
|
48 | 46 | url = '%sapi/files/%s?key=%s' % (host, intermediatefileid, key) |
| 47 | + result = connector.get(url, stream=True, verify=connector.ssl_verify if connector else True) |
| 48 | + |
49 | 49 | (inputfile, inputfilename) = tempfile.mkstemp(suffix=ext) |
50 | 50 |
|
51 | 51 | try: |
52 | | - if os.getenv('STREAM', '').lower() == 'pycurl': |
53 | | - with os.fdopen(inputfile, "wb") as outputfile: |
54 | | - c = pycurl.Curl() |
55 | | - if connector and not connector.ssl_verify: |
56 | | - c.setopt(pycurl.SSL_VERIFYPEER, 0) |
57 | | - c.setopt(pycurl.SSL_VERIFYHOST, 0) |
58 | | - c.setopt(c.URL, url) |
59 | | - c.setopt(c.WRITEDATA, outputfile) |
60 | | - c.setopt(c.CAINFO, certifi.where()) |
61 | | - c.perform() |
62 | | - c.close() |
63 | | - else: |
64 | | - result = connector.get(url, stream=True, verify=connector.ssl_verify if connector else True) |
65 | | - with os.fdopen(inputfile, "wb") as outputfile: |
66 | | - for chunk in result.iter_content(chunk_size=10 * 1024): |
67 | | - outputfile.write(chunk) |
68 | | - return inputfilename |
| 52 | + with os.fdopen(inputfile, "wb") as outputfile: |
| 53 | + for chunk in result.iter_content(chunk_size=10*1024): |
| 54 | + outputfile.write(chunk) |
| 55 | + return inputfilename |
69 | 56 | except Exception: |
70 | 57 | os.remove(inputfilename) |
71 | 58 | raise |
|
0 commit comments