From: Steven Black Date: Sat, 2 Jan 2016 23:57:23 +0000 (-0500) Subject: Better handling of download errors. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=eeb6c54b139289e2ae0b6c34e4a87e21af6f849d;p=stevenblack-hosts.git Better handling of download errors. --- 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 )