From a423789a3d96c7be0c2b01050a3eca8a3c223b6e Mon Sep 17 00:00:00 2001 From: Caohongtao Date: Thu, 16 May 2024 10:05:16 +0000 Subject: [PATCH] Optimize the code! Signed-off-by: Caohongtao --- sysmonitor-1.3.2/script/clocktransition.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sysmonitor-1.3.2/script/clocktransition.py b/sysmonitor-1.3.2/script/clocktransition.py index 4db95c3..be7298f 100755 --- a/sysmonitor-1.3.2/script/clocktransition.py +++ b/sysmonitor-1.3.2/script/clocktransition.py @@ -60,9 +60,7 @@ def start_dhclient_task(cmd): def check_cmd_user(cmd_user): """check cmd user is root""" - std_cmd_user = "root" - if cmd_user: - if cmd_user == std_cmd_user: + if cmd_user == "root": return True return False @@ -83,8 +81,8 @@ def check_cmd_name(cmd_line): def reset_dhclient(): """find and kill dhclient process and start new dhclient""" - ret, ps_result = subprocess.getstatusoutput(("ps -eLwwo user,pid,args|" - "grep -w /sbin/dhclient|grep -v grep")) + ret, ps_result = subprocess.getstatusoutput("ps -eLwwo user,pid,args|" + "grep -w /sbin/dhclient|grep -v grep") if ret != 0: return -- Gitee