mirror of
https://github.com/StevenBlack/hosts.git
synced 2024-07-06 12:32:35 +02:00
Changed variable
changed variable name of dnsFlushedOccured to dnsCacheFound to better indicate what the value represents
This commit is contained in:
parent
408069da79
commit
0649aa1c8c
@ -407,42 +407,42 @@ def updateReadme(numberOfRules):
|
|||||||
|
|
||||||
def moveHostsFileIntoPlace(finalFile):
|
def moveHostsFileIntoPlace(finalFile):
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
dnsFlushOccured = False
|
dnsCacheFound = False
|
||||||
print ("Moving the file requires administrative privileges. " +
|
print ("Moving the file requires administrative privileges. " +
|
||||||
"You might need to enter your password.")
|
"You might need to enter your password.")
|
||||||
if subprocess.call(["/usr/bin/sudo", "cp", os.path.abspath(finalFile.name), "/etc/hosts"]):
|
if subprocess.call(["/usr/bin/sudo", "cp", os.path.abspath(finalFile.name), "/etc/hosts"]):
|
||||||
printFailure("Moving the file failed.")
|
printFailure("Moving the file failed.")
|
||||||
print ("Flushing the DNS Cache to utilize new hosts file...")
|
print ("Flushing the DNS Cache to utilize new hosts file...")
|
||||||
if platform.system() == 'Darwin':
|
if platform.system() == 'Darwin':
|
||||||
dnsFlushOccured = True
|
dnsCacheFound = True
|
||||||
if subprocess.call(["/usr/bin/sudo", "killall", "-HUP", "mDNSResponder"]):
|
if subprocess.call(["/usr/bin/sudo", "killall", "-HUP", "mDNSResponder"]):
|
||||||
printFailure("Flushing the DNS Cache failed.")
|
printFailure("Flushing the DNS Cache failed.")
|
||||||
else:
|
else:
|
||||||
if os.path.isfile("/etc/rc.d/init.d/nscd"):
|
if os.path.isfile("/etc/rc.d/init.d/nscd"):
|
||||||
dnsFlushOccured = True
|
dnsCacheFound = True
|
||||||
if subprocess.call(["/usr/bin/sudo", "/etc/rc.d/init.d/nscd", "restart"]):
|
if subprocess.call(["/usr/bin/sudo", "/etc/rc.d/init.d/nscd", "restart"]):
|
||||||
printFailure("Flushing the DNS Cache failed.")
|
printFailure("Flushing the DNS Cache failed.")
|
||||||
else:
|
else:
|
||||||
printSuccess("Flushing DNS by restarting nscd succeeded")
|
printSuccess("Flushing DNS by restarting nscd succeeded")
|
||||||
if os.path.isfile("/usr/lib/systemd/system/NetworkManager.service"):
|
if os.path.isfile("/usr/lib/systemd/system/NetworkManager.service"):
|
||||||
dnsFlushOccured = True
|
dnsCacheFound = True
|
||||||
if subprocess.call(["/usr/bin/sudo", "/usr/bin/systemctl", "restart", "NetworkManager.service"]):
|
if subprocess.call(["/usr/bin/sudo", "/usr/bin/systemctl", "restart", "NetworkManager.service"]):
|
||||||
printFailure("Flushing the DNS Cache failed.")
|
printFailure("Flushing the DNS Cache failed.")
|
||||||
else:
|
else:
|
||||||
printSuccess("Flushing DNS by restarting NetworkManager succeeded")
|
printSuccess("Flushing DNS by restarting NetworkManager succeeded")
|
||||||
if os.path.isfile("/usr/lib/systemd/system/wicd.service"):
|
if os.path.isfile("/usr/lib/systemd/system/wicd.service"):
|
||||||
dnsFlushOccured = True
|
dnsCacheFound = True
|
||||||
if subprocess.call(["/usr/bin/sudo", "/usr/bin/systemctl", "restart", "wicd.service"]):
|
if subprocess.call(["/usr/bin/sudo", "/usr/bin/systemctl", "restart", "wicd.service"]):
|
||||||
printFailure("Flushing the DNS Cache failed.")
|
printFailure("Flushing the DNS Cache failed.")
|
||||||
else:
|
else:
|
||||||
printSuccess("Flushing DNS by restarting wicd succeeded")
|
printSuccess("Flushing DNS by restarting wicd succeeded")
|
||||||
if os.path.isfile("/usr/lib/systemd/system/dnsmasq.service"):
|
if os.path.isfile("/usr/lib/systemd/system/dnsmasq.service"):
|
||||||
dnsFlushOccured = True
|
dnsCacheFound = True
|
||||||
if subprocess.call(["/usr/bin/sudo", "/usr/bin/systemctl", "restart", "dnsmasq.service"]):
|
if subprocess.call(["/usr/bin/sudo", "/usr/bin/systemctl", "restart", "dnsmasq.service"]):
|
||||||
printFailure("Flushing the DNS Cache failed.")
|
printFailure("Flushing the DNS Cache failed.")
|
||||||
else:
|
else:
|
||||||
printSuccess("Flushing DNS by restarting dnsmasq succeeded")
|
printSuccess("Flushing DNS by restarting dnsmasq succeeded")
|
||||||
if not dnsFlushOccured:
|
if not dnsCacheFound:
|
||||||
printFailure("Unable to determine DNS management tool.")
|
printFailure("Unable to determine DNS management tool.")
|
||||||
elif os.name == 'nt':
|
elif os.name == 'nt':
|
||||||
print ("Automatically moving the hosts file in place is not yet supported.")
|
print ("Automatically moving the hosts file in place is not yet supported.")
|
||||||
|
Loading…
Reference in New Issue
Block a user