Doc / Check for Centos restart
authorgfyoung <redacted>
Wed, 23 May 2018 01:39:00 +0000 (21:39 -0400)
committergfyoung <redacted>
Wed, 23 May 2018 01:53:56 +0000 (21:53 -0400)
Closes gh-622.

readme_template.md
testUpdateHostsFile.py
updateHostsFile.py

index c6facae07e607f6299fd3ccea01147b7a2f77ece..ade1a75f7fbb0f469013f318a29fa4ab7978b306 100644 (file)
@@ -303,6 +303,8 @@ Open a Terminal and run with root privileges:
 
 **Arch Linux/Manjaro with Wicd**: `sudo systemctl restart wicd.service`
 
+**RHEL/Centos**: `sudo /etc/init.d/network restart`
+
 **Others**: Consult [this wikipedia article](https://en.wikipedia.org/wiki/Hosts_%28file%29#Location_in_the_file_system).
 
 ### Mac OS X
index cb88c7a5bce9dc3100ce18c30be1b1cb70d8f9fc..4b4a7c9ff94fbebaed15c980282ae0229bdff6ce 100644 (file)
@@ -1186,7 +1186,7 @@ class TestFlushDnsCache(BaseStdout):
                 output = sys.stdout.getvalue()
                 self.assertIn(expected, output)
 
-    @mock.patch("os.path.isfile", side_effect=[True] + [False] * 10)
+    @mock.patch("os.path.isfile", side_effect=[True] + [False] * 11)
     @mock.patch("subprocess.call", return_value=0)
     def test_flush_posix(self, *_):
         with self.mock_property("platform.system") as obj:
@@ -1201,7 +1201,7 @@ class TestFlushDnsCache(BaseStdout):
                 output = sys.stdout.getvalue()
                 self.assertIn(expected, output)
 
-    @mock.patch("os.path.isfile", side_effect=[True] + [False] * 10)
+    @mock.patch("os.path.isfile", side_effect=[True] + [False] * 11)
     @mock.patch("subprocess.call", return_value=1)
     def test_flush_posix_fail(self, *_):
         with self.mock_property("platform.system") as obj:
@@ -1216,7 +1216,7 @@ class TestFlushDnsCache(BaseStdout):
                 output = sys.stdout.getvalue()
                 self.assertIn(expected, output)
 
-    @mock.patch("os.path.isfile", side_effect=[True, False,
+    @mock.patch("os.path.isfile", side_effect=[True, False, False,
                                                True] + [False] * 10)
     @mock.patch("subprocess.call", side_effect=[1, 0])
     def test_flush_posix_fail_then_succeed(self, *_):
index c775ed65e94bc1c3bd63e8526a6ea558264cd935..4f08e676d8546f79c3da4d4338b367c7d1737a7c 100644 (file)
@@ -1063,6 +1063,15 @@ def flush_dns_cache():
                 else:
                     print_success(nscd_msg.format(result="succeeded"))
 
+        centos_file = "/etc/init.d/network"
+        centos_msg = "Flushing the DNS cache by restarting network {result}"
+
+        if os.path.isfile(centos_file):
+            if subprocess.call(SUDO + [centos_file, "restart"]):
+                print_failure(centos_msg.format(result="failed"))
+            else:
+                print_success(centos_msg.format(result="succeeded"))
+
         system_prefixes = ["/usr", ""]
         service_types = ["NetworkManager", "wicd", "dnsmasq", "networking"]
 
git clone https://git.99rst.org/PROJECT