File bcc-bsc1080085-fix-cachetop-py3-str.patch of Package bcc.13112

From fedd277132f7d28a1cc96ce37aa931a999c0025c Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Tue, 13 Feb 2018 18:02:42 +0800
Subject: [PATCH] cachetop: convert str to bytes

Signed-off-by: Gary Lin <glin@suse.com>
---
 tools/cachetop.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/cachetop.py b/tools/cachetop.py
index 5afd3fa..16f45d6 100755
--- a/tools/cachetop.py
+++ b/tools/cachetop.py
@@ -18,12 +18,12 @@ from __future__ import division
 # from __future__ import unicode_literals
 from __future__ import print_function
 
+import curses
 from bcc import BPF
 from collections import defaultdict
 from time import strftime
 
 import argparse
-import curses
 import pwd
 import re
 import signal
@@ -52,8 +52,8 @@ def signal_ignore(signal, frame):
 def get_meminfo():
     result = {}
 
-    for line in open('/proc/meminfo'):
-        k = line.split(':', 3)
+    for line in open('/proc/meminfo', "rb"):
+        k = line.split(b':', 3)
         v = k[1].split()
         result[k[0]] = int(v[0])
     return result
@@ -88,16 +88,16 @@ def get_processes_stats(
         whits = 0
 
         for k, v in count.items():
-            if re.match('mark_page_accessed', bpf.ksym(k)) is not None:
+            if re.match(b'mark_page_accessed', bpf.ksym(k)) is not None:
                 mpa = max(0, v)
 
-            if re.match('mark_buffer_dirty', bpf.ksym(k)) is not None:
+            if re.match(b'mark_buffer_dirty', bpf.ksym(k)) is not None:
                 mbd = max(0, v)
 
-            if re.match('add_to_page_cache_lru', bpf.ksym(k)) is not None:
+            if re.match(b'add_to_page_cache_lru', bpf.ksym(k)) is not None:
                 apcl = max(0, v)
 
-            if re.match('account_page_dirtied', bpf.ksym(k)) is not None:
+            if re.match(b'account_page_dirtied', bpf.ksym(k)) is not None:
                 apd = max(0, v)
 
             # access = total cache access incl. reads(mpa) and writes(mbd)
@@ -195,8 +195,8 @@ def handle_loop(stdscr, args):
 
         # Get memory info
         mem = get_meminfo()
-        cached = int(mem["Cached"]) / 1024
-        buff = int(mem["Buffers"]) / 1024
+        cached = int(mem[b"Cached"]) / 1024
+        buff = int(mem[b"Buffers"]) / 1024
 
         process_stats = get_processes_stats(
             b,
-- 
2.16.1

openSUSE Build Service is sponsored by