[PATCH 3/3] hwlatdetect: make reading sample date work with python2 and python3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Clark Williams <williams@xxxxxxxxxx>

Modify the sample reading code to return correct string data and to
catch exceptions in non-blocking mode correctly on python{2,3}

Signed-off-by: Clark Williams <williams@xxxxxxxxxx>
Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
---
 src/hwlatdetect/hwlatdetect.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index c8c86ad189ca..d9ef0272d738 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -79,15 +79,21 @@ class DebugFS(object):
             val = f.readline()
             f.close()
         else:
-            fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK)
+            f = os.fdopen(os.open(path, os.O_RDONLY|os.O_NONBLOCK), "r")
             try:
-                val = os.read(fd, 256)
+                val = f.readline()
             except OSError as e:
+                print ("errno: %s" % e)
                 if e.errno == errno.EAGAIN:
                     val = None
                 else:
                     raise
-            os.close(fd)
+            except IOError as e:
+                if e.errno == errno.EAGAIN:
+                    val = None
+                else:
+                    raise
+            f.close()
         return val
 
     def putval(self, item, value):
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux