public inbox for linux-rt-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Punit Agrawal <punitagrawal@gmail.com>
To: jkacur@redhat.com
Cc: Punit Agrawal <punitagrawal@gmail.com>,
	linux-rt-users@vger.kernel.org, punit1.agrawal@toshiba.co.jp
Subject: [PATCH 2/2] rteval: services.py: Fix incorrect detection of container environment
Date: Thu,  9 Sep 2021 17:05:47 +0900	[thread overview]
Message-ID: <20210909080547.1331581-3-punitagrawal@gmail.com> (raw)
In-Reply-To: <20210909080547.1331581-1-punitagrawal@gmail.com>

From: Punit Agrawal <punit1.agrawal@toshiba.co.jp>

rteval mistakenly detects that it is running inside a container even
though it is running directly on the host. On further investigation
this was found to be due to change in behaviour around byte strings
and strings when going from python2 to python3.

In python3 byte strings are not equivalent to strings, i.e., b'' == ''
is False. The string comparison functions in services.py are still
relying on the old behaviour in python2 where they were equivalent.

Update the byte string processing by converting them to string.

Signed-off-by: Punit Agrawal <punit1.agrawal@toshiba.co.jp>
---
 rteval/sysinfo/services.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/rteval/sysinfo/services.py b/rteval/sysinfo/services.py
index 06ff5ae9cd0c..94857aea6be4 100644
--- a/rteval/sysinfo/services.py
+++ b/rteval/sysinfo/services.py
@@ -83,8 +83,8 @@ class SystemServices:
         self.__log(Log.DEBUG, "cmd: %s" % cmd)
         c = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         for p in c.stdout:
-            # p are lines like "servicename.service status"
-            v = p.strip().split()
+            # p are lines like b'servicename.service status'
+            v = p.decode().strip().split()
             ret_services[v[0].split('.')[0]] = v[1]
         return ret_services
 
@@ -92,7 +92,7 @@ class SystemServices:
     def services_get(self):
         cmd = [getcmdpath('ps'), '-ocomm=', '1']
         c = subprocess.Popen(cmd, stdout=subprocess.PIPE)
-        self.__init = c.stdout.read().strip()
+        self.__init = c.stdout.read().decode().strip()
         if self.__init == 'systemd':
             self.__log(Log.DEBUG, "Using systemd to get services status")
             return self.__get_services_systemd()
-- 
2.32.0


  parent reply	other threads:[~2021-09-09  8:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-09  8:05 [PATCH 0/2] rteval: Miscellaneous fixes Punit Agrawal
2021-09-09  8:05 ` [PATCH 1/2] rteval: osinfo.py: Fix RT kernel detection Punit Agrawal
2021-09-10 16:30   ` John Kacur
2021-09-09  8:05 ` Punit Agrawal [this message]
2021-09-12 14:59   ` [PATCH 2/2] rteval: services.py: Fix incorrect detection of container environment John Kacur
2021-09-13  7:47     ` Punit Agrawal
2021-09-13  8:06     ` [PATCH v2] " Punit Agrawal
2021-09-13 13:33       ` John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210909080547.1331581-3-punitagrawal@gmail.com \
    --to=punitagrawal@gmail.com \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=punit1.agrawal@toshiba.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox