Merge pull request #1339 from codeswhite/patch-systemctl-restart-check

Check if a service is running (Fixed #1337)
This commit is contained in:
Steven Black
2020-07-11 10:39:13 -04:00
committed by GitHub
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -1324,7 +1324,7 @@ class TestFlushDnsCache(BaseStdout):
self.assertIn(expected, output)
@mock.patch("os.path.isfile", side_effect=[True, False, False, True] + [False] * 10)
@mock.patch("subprocess.call", side_effect=[1, 0])
@mock.patch("subprocess.call", side_effect=[1, 0, 0])
def test_flush_posix_fail_then_succeed(self, *_):
with self.mock_property("platform.system") as obj:
obj.return_value = "Linux"
+3
View File
@@ -1306,6 +1306,9 @@ def flush_dns_cache():
)
if os.path.isfile(service_file):
if 0 != subprocess.call([systemctl, "status", service],
stdout=subprocess.DEVNULL):
continue
dns_cache_found = True
if subprocess.call(SUDO + [systemctl, "restart", service]):