donate-cpu.py: Fix crash when wget destination file does not exist. (#1368)
When os.remove() tried to remove a file that did not exist (which is the case when the script is started for the first time or the working directory has been cleared) a FileNotFoundError was issued and the script just crashed.
This commit is contained in:
parent
5a2362b2a0
commit
7fdd039bee
|
@ -126,7 +126,12 @@ def removeTree(folderName):
|
|||
|
||||
|
||||
def wget(url, destfile):
|
||||
os.remove(destfile)
|
||||
if os.path.exists(destfile):
|
||||
if os.path.isfile(destfile):
|
||||
os.remove(destfile)
|
||||
else:
|
||||
print('Error: ' + destfile + ' exists but it is not a file! Please check the path and delete it manually.')
|
||||
sys.exit(1)
|
||||
subprocess.call(
|
||||
['wget', '--tries=10', '--timeout=300', '-O', destfile, url])
|
||||
if os.path.isfile(destfile):
|
||||
|
|
Loading…
Reference in New Issue