From eeb6c54b139289e2ae0b6c34e4a87e21af6f849d Mon Sep 17 00:00:00 2001 From: Steven Black Date: Sat, 2 Jan 2016 18:57:23 -0500 Subject: [PATCH] Better handling of download errors. --- updateHostsFile.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/updateHostsFile.py b/updateHostsFile.py index ae13d1771..7dea797c5 100755 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -180,12 +180,16 @@ def updateAllSources(): print ( 'Updating source ' + source + ' from ' + updateURL ) # Cross-python call updatedFile = getFileByUrl( updateURL ); - updatedFile = updatedFile.replace( '\r', '' ) #get rid of carriage-return symbols - # This is cross-python code - dataFile = open( os.path.join( DATA_PATH, source, DATA_FILENAMES ), 'wb' ) - writeData( dataFile, updatedFile ); - dataFile.close() + try: + updatedFile = updatedFile.replace( '\r', '' ) #get rid of carriage-return symbols + # This is cross-python code + dataFile = open( os.path.join( DATA_PATH, source, DATA_FILENAMES ), 'wb' ) + writeData( dataFile, updatedFile ); + dataFile.close() + except: + print ( "Skipping." ); + def getUpdateURLFromFile( source ): pathToUpdateFile = os.path.join( DATA_PATH, source, UPDATE_URL_FILENAME )