From 4956dfd4297c48611773b0cfaac1c96899fa3fe8 Mon Sep 17 00:00:00 2001 From: sunilkumarn417 Date: Tue, 18 Aug 2020 13:33:04 +0530 Subject: [PATCH] Fix py3 comparison issue(None with integers) in pid method and Fix split issue which creates empty string value due to newline character at end of command response. Signed-off-by: sunilkumarn417 --- teuthology/orchestra/daemon/systemd.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/teuthology/orchestra/daemon/systemd.py b/teuthology/orchestra/daemon/systemd.py index 03d00eca82..204f9422c6 100644 --- a/teuthology/orchestra/daemon/systemd.py +++ b/teuthology/orchestra/daemon/systemd.py @@ -85,7 +85,7 @@ class SystemDState(DaemonState): # Main process exited, code=exited, status=1/FAILURE self.status_cmd + " | grep 'Main.*code=exited'", ) - line = out.split('\n')[-1] + line = out.strip().split('\n')[-1] exit_code = int(re.match('.*status=(\d+).*', line).groups()[0]) if exit_code: self.remote.run( @@ -167,10 +167,12 @@ class SystemDState(DaemonState): :return: The PID if remote run command value is set, False otherwise. """ pid = self.pid - if pid > 0: - return pid - else: + if pid is None: + return None + elif pid <= 0: return None + else: + return pid def signal(self, sig, silent=False): """ -- 2.39.5