From d520b40f402be56d71e3c1aa35883f40c42e1d27 Mon Sep 17 00:00:00 2001 From: wuzhaomin Date: Tue, 9 Jul 2024 09:41:54 +0800 Subject: [PATCH] The f_exists function is added to the conf_check.py file --- common/conf_check.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/conf_check.py b/common/conf_check.py index 46b374c..ef42928 100644 --- a/common/conf_check.py +++ b/common/conf_check.py @@ -2,6 +2,7 @@ #!/usr/bin/env python # cython:language_level=3 from common.command import Command +import subprocess,shlex class ConfCheck: def pid(process): @@ -26,3 +27,15 @@ class ConfCheck: p_list.pop(0) p_list.pop(-1) return p_list + + @staticmethod + def f_exists(file = ''): + if file == '': + return False + devnull = open("/dev/null", "w") + ret = subprocess.Popen(shlex('test -e ' + file), stdout = devnull, stderr = devnull) + ret.communicate() + if 0 == ret.returncode: + return True + else: + return False -- Gitee