]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Fix py3 comparison issue(None with integers) in pid method and 1549/head
authorsunilkumarn417 <sunnagar@redhat.com>
Tue, 18 Aug 2020 08:03:04 +0000 (13:33 +0530)
committersunilkumarn417 <sunnagar@redhat.com>
Tue, 18 Aug 2020 15:25:20 +0000 (20:55 +0530)
Fix split issue which creates empty string value due to newline character at
end of command response.

Signed-off-by: sunilkumarn417 <sunnagar@redhat.com>
teuthology/orchestra/daemon/systemd.py

index 03d00eca825f5725ea065645d0e0f58ec1c62449..204f9422c698fee01eca1a72fc50ec3574f6507e 100644 (file)
@@ -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):
         """