Better handling of download errors.
authorSteven Black <redacted>
Sat, 2 Jan 2016 23:57:23 +0000 (18:57 -0500)
committerSteven Black <redacted>
Sat, 2 Jan 2016 23:57:23 +0000 (18:57 -0500)
updateHostsFile.py

index ae13d1771efbd2bc28e9cf4dc6497c2d0db6ca9f..7dea797c53462ec8404ef48ab81a1710e34db1b8 100755 (executable)
@@ -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 )
git clone https://git.99rst.org/PROJECT