Commit 9e4208be authored by Suresh V's avatar Suresh V

implement for all downloaders and check file existence before removing

parent 115bb41b
......@@ -162,7 +162,12 @@ def download_file_powershell(url, target):
'-Command',
"(new-object System.Net.WebClient).DownloadFile(%(url)r, %(target)r)" % vars(),
]
subprocess.check_call(cmd)
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
if os.access(target, os.F_OK):
os.unlink(target)
raise
def has_powershell():
if platform.system() != 'Windows':
......@@ -182,7 +187,12 @@ download_file_powershell.viable = has_powershell
def download_file_curl(url, target):
cmd = ['curl', url, '--silent', '--output', target]
subprocess.check_call(cmd)
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
if os.access(target, os.F_OK):
os.unlink(target)
raise
def has_curl():
cmd = ['curl', '--version']
......@@ -203,7 +213,8 @@ def download_file_wget(url, target):
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
os.unlink(target)
if os.access(target, os.F_OK):
os.unlink(target)
raise
def has_wget():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment