Skip to content

Commit

Permalink
URLGetter now has a download_to_file() function
Browse files Browse the repository at this point in the history
  • Loading branch information
nmcspadden committed Nov 27, 2019
1 parent 079c606 commit 2fac695
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Code/autopkglib/URLGetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ def download(self, url, headers=None, text=False):

return output

def download_to_file(self, url, filename, headers=None):
"""Download content to a file with default curl options"""
curl_cmd = self.prepare_curl_cmd()
self.add_curl_headers(curl_cmd, headers)
curl_cmd.append(url)
curl_cmd.extend(["-o", filename])
self.download_with_curl(curl_cmd, text=False)
if os.path.exists(filename):
return filename
raise ProcessorError(f"{filename} was not written!")

def main(self):
pass

Expand Down

0 comments on commit 2fac695

Please sign in to comment.