From 79b60c1cebdc6e97a99980d168aef6dc244c510f Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Tue, 11 Jan 2011 12:34:19 +0100 Subject: [PATCH] utils: Drop RemovePidFile It's equivalent to a simple RemoveFile now. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/daemon.py | 2 +- lib/utils/io.py | 16 ---------------- test/ganeti.utils.io_unittest.py | 8 ++++---- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/lib/daemon.py b/lib/daemon.py index 15b89bf35..c26a17625 100644 --- a/lib/daemon.py +++ b/lib/daemon.py @@ -682,4 +682,4 @@ def GenericMain(daemon_name, optionparser, exec_fn(options, args, prep_results) finally: - utils.RemovePidFile(utils.DaemonPidFileName(daemon_name)) + utils.RemoveFile(utils.DaemonPidFileName(daemon_name)) diff --git a/lib/utils/io.py b/lib/utils/io.py index e6f98735e..bdf677e44 100644 --- a/lib/utils/io.py +++ b/lib/utils/io.py @@ -707,22 +707,6 @@ def WritePidFile(pidfile): return fd_pidfile -def RemovePidFile(pidfile): - """Remove the current process pidfile. - - Any errors are ignored. - - @type pidfile: string - @param pidfile: Path to the file to be removed - - """ - # TODO: we could check here that the file contains our pid - try: - RemoveFile(pidfile) - except Exception: # pylint: disable-msg=W0703 - pass - - def ReadWatcherPauseFile(filename, now=None, remove_after=3600): """Reads the watcher pause file. diff --git a/test/ganeti.utils.io_unittest.py b/test/ganeti.utils.io_unittest.py index 43b4634b4..b445abe05 100755 --- a/test/ganeti.utils.io_unittest.py +++ b/test/ganeti.utils.io_unittest.py @@ -568,7 +568,7 @@ class TestTailFile(testutils.GanetiTestCase): class TestPidFileFunctions(unittest.TestCase): - """Tests for WritePidFile, RemovePidFile and ReadPidFile""" + """Tests for WritePidFile and ReadPidFile""" def setUp(self): self.dir = tempfile.mkdtemp() @@ -585,7 +585,7 @@ class TestPidFileFunctions(unittest.TestCase): self.failUnlessRaises(errors.LockError, utils.WritePidFile, self.f_dpn('test')) os.close(fd) - utils.RemovePidFile(self.f_dpn("test")) + utils.RemoveFile(self.f_dpn("test")) self.failIf(os.path.exists(pid_file), "PID file should not exist anymore") self.failUnlessEqual(utils.ReadPidFile(pid_file), 0, @@ -598,7 +598,7 @@ class TestPidFileFunctions(unittest.TestCase): # but now, even with the file existing, we should be able to lock it fd = utils.WritePidFile(self.f_dpn('test')) os.close(fd) - utils.RemovePidFile(self.f_dpn("test")) + utils.RemoveFile(self.f_dpn("test")) self.failIf(os.path.exists(pid_file), "PID file should not exist anymore") @@ -620,7 +620,7 @@ class TestPidFileFunctions(unittest.TestCase): self.failUnless(utils.IsProcessAlive(new_pid)) utils.KillProcess(new_pid, waitpid=True) self.failIf(utils.IsProcessAlive(new_pid)) - utils.RemovePidFile(self.f_dpn('child')) + utils.RemoveFile(self.f_dpn('child')) self.failUnlessRaises(errors.ProgrammerError, utils.KillProcess, 0) def tearDown(self): -- GitLab