Making it work in Python3.
authorSteven Black <redacted>
Sun, 13 Mar 2016 15:59:25 +0000 (11:59 -0400)
committerSteven Black <redacted>
Sun, 13 Mar 2016 15:59:25 +0000 (11:59 -0400)
updateHostsFile.py

index 15de680e8361e7adf27c499c8ba7be98fef87cde..cff6fe56192856d0efd873afc840ba6be8edc657 100644 (file)
@@ -292,9 +292,12 @@ def removeDupsAndExcl(mergeFile):
         os.makedirs(outputPath)
 
     # Another mode is required to read and write the file in Python 3
-    finalFile = open(os.path.join(outputPath, 'hosts'), 'r+')
-    mergeFile.seek(0) # reset file pointer
+    if Python3:
+        finalFile = open(os.path.join(outputPath, 'hosts'), 'w+b')
+    else:
+        finalFile = open(os.path.join(outputPath, 'hosts'), 'w+')
 
+    mergeFile.seek(0) # reset file pointer
     hostnames = set()
     hostnames.add("localhost")
     hostnames.add("localhost.localdomain")
git clone https://git.99rst.org/PROJECT