Only process source folders, and not files that may be present.
authorSteven Black <redacted>
Tue, 23 Feb 2016 14:50:20 +0000 (09:50 -0500)
committerSteven Black <redacted>
Tue, 23 Feb 2016 14:50:20 +0000 (09:50 -0500)
updateHostsFile.py

index 4b58f47e8f66bdc31894bb3d37d8222014651994..1c6130dc11045f620d3b8d321a7cdbdbe003b38c 100644 (file)
@@ -61,7 +61,6 @@ def myInput(msg = ""):
     else:
         return raw_input(msg)
 
-
 # Cross-python writing function
 def writeData(f, data):
     if Python3:
@@ -212,21 +211,22 @@ def matchesExclusions(strippedRule):
 def updateAllSources():
     allsources = list(set(SOURCES) | set(EXTENSIONS))
     for source in allsources:
-        updateURL = getUpdateURLFromFile(source)
-        if updateURL is None:
-            continue
-        print ("Updating source " + os.path.basename(source) + " from " + updateURL)
-        # Cross-python call
-        updatedFile = getFileByUrl(updateURL)
-
-        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.")
+        if os.path.isdir(source):
+            updateURL = getUpdateURLFromFile(source)
+            if updateURL is None:
+                continue
+            print ("Updating source " + os.path.basename(source) + " from " + updateURL)
+            # Cross-python call
+            updatedFile = getFileByUrl(updateURL)
+
+            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