diff mbox series

[SRU,Bionic,1/2] tools/kvm_stat: fix python3 issues

Message ID 20190115101754.16508-1-juergh@canonical.com
State New
Headers show
Series [SRU,Bionic,1/2] tools/kvm_stat: fix python3 issues | expand

Commit Message

Juerg Haefliger Jan. 15, 2019, 10:17 a.m. UTC
From: Stefan Raspl <stefan.raspl@de.ibm.com>

BugLink: https://bugs.launchpad.net/bugs/1798776

Python3 returns a float for a regular division - switch to a division
operator that returns an integer.
Furthermore, filters return a generator object instead of the actual
list - wrap result in yet another list, which makes it still work in
both, Python2 and 3.

Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
(cherry picked from commit 58f33cfe73076b6497bada4f7b5bda961ed68083)
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 tools/kvm/kvm_stat/kvm_stat | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Stefan Bader Jan. 21, 2019, 2:08 p.m. UTC | #1
On 15.01.19 11:17, Juerg Haefliger wrote:
> From: Stefan Raspl <stefan.raspl@de.ibm.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1798776
> 
> Python3 returns a float for a regular division - switch to a division
> operator that returns an integer.
> Furthermore, filters return a generator object instead of the actual
> list - wrap result in yet another list, which makes it still work in
> both, Python2 and 3.
> 
> Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> (cherry picked from commit 58f33cfe73076b6497bada4f7b5bda961ed68083)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---
>  tools/kvm/kvm_stat/kvm_stat | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
> index 56c4b3f8a01b..e10b90a8917a 100755
> --- a/tools/kvm/kvm_stat/kvm_stat
> +++ b/tools/kvm/kvm_stat/kvm_stat
> @@ -759,7 +759,7 @@ class DebugfsProvider(Provider):
>              if len(vms) == 0:
>                  self.do_read = False
>  
> -            self.paths = filter(lambda x: "{}-".format(pid) in x, vms)
> +            self.paths = list(filter(lambda x: "{}-".format(pid) in x, vms))
>  
>          else:
>              self.paths = []
> @@ -1219,10 +1219,10 @@ class Tui(object):
>          (x, term_width) = self.screen.getmaxyx()
>          row = 2
>          for line in text:
> -            start = (term_width - len(line)) / 2
> +            start = (term_width - len(line)) // 2
>              self.screen.addstr(row, start, line)
>              row += 1
> -        self.screen.addstr(row + 1, (term_width - len(hint)) / 2, hint,
> +        self.screen.addstr(row + 1, (term_width - len(hint)) // 2, hint,
>                             curses.A_STANDOUT)
>          self.screen.getkey()
>  
>
Kleber Sacilotto de Souza Jan. 31, 2019, 4:12 p.m. UTC | #2
On 1/15/19 11:17 AM, Juerg Haefliger wrote:
> From: Stefan Raspl <stefan.raspl@de.ibm.com>
>
> BugLink: https://bugs.launchpad.net/bugs/1798776
>
> Python3 returns a float for a regular division - switch to a division
> operator that returns an integer.
> Furthermore, filters return a generator object instead of the actual
> list - wrap result in yet another list, which makes it still work in
> both, Python2 and 3.
>
> Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> (cherry picked from commit 58f33cfe73076b6497bada4f7b5bda961ed68083)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
> ---
>  tools/kvm/kvm_stat/kvm_stat | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
> index 56c4b3f8a01b..e10b90a8917a 100755
> --- a/tools/kvm/kvm_stat/kvm_stat
> +++ b/tools/kvm/kvm_stat/kvm_stat
> @@ -759,7 +759,7 @@ class DebugfsProvider(Provider):
>              if len(vms) == 0:
>                  self.do_read = False
>  
> -            self.paths = filter(lambda x: "{}-".format(pid) in x, vms)
> +            self.paths = list(filter(lambda x: "{}-".format(pid) in x, vms))
>  
>          else:
>              self.paths = []
> @@ -1219,10 +1219,10 @@ class Tui(object):
>          (x, term_width) = self.screen.getmaxyx()
>          row = 2
>          for line in text:
> -            start = (term_width - len(line)) / 2
> +            start = (term_width - len(line)) // 2
>              self.screen.addstr(row, start, line)
>              row += 1
> -        self.screen.addstr(row + 1, (term_width - len(hint)) / 2, hint,
> +        self.screen.addstr(row + 1, (term_width - len(hint)) // 2, hint,
>                             curses.A_STANDOUT)
>          self.screen.getkey()
>
Khalid Elmously Feb. 1, 2019, 3:18 a.m. UTC | #3
On 2019-01-15 11:17:53 , Juerg Haefliger wrote:
> From: Stefan Raspl <stefan.raspl@de.ibm.com>
> 
> BugLink: https://bugs.launchpad.net/bugs/1798776
> 
> Python3 returns a float for a regular division - switch to a division
> operator that returns an integer.
> Furthermore, filters return a generator object instead of the actual
> list - wrap result in yet another list, which makes it still work in
> both, Python2 and 3.
> 
> Signed-off-by: Stefan Raspl <raspl@linux.ibm.com>
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> (cherry picked from commit 58f33cfe73076b6497bada4f7b5bda961ed68083)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  tools/kvm/kvm_stat/kvm_stat | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
> index 56c4b3f8a01b..e10b90a8917a 100755
> --- a/tools/kvm/kvm_stat/kvm_stat
> +++ b/tools/kvm/kvm_stat/kvm_stat
> @@ -759,7 +759,7 @@ class DebugfsProvider(Provider):
>              if len(vms) == 0:
>                  self.do_read = False
>  
> -            self.paths = filter(lambda x: "{}-".format(pid) in x, vms)
> +            self.paths = list(filter(lambda x: "{}-".format(pid) in x, vms))
>  
>          else:
>              self.paths = []
> @@ -1219,10 +1219,10 @@ class Tui(object):
>          (x, term_width) = self.screen.getmaxyx()
>          row = 2
>          for line in text:
> -            start = (term_width - len(line)) / 2
> +            start = (term_width - len(line)) // 2
>              self.screen.addstr(row, start, line)
>              row += 1
> -        self.screen.addstr(row + 1, (term_width - len(hint)) / 2, hint,
> +        self.screen.addstr(row + 1, (term_width - len(hint)) // 2, hint,
>                             curses.A_STANDOUT)
>          self.screen.getkey()
>  
> -- 
> 2.19.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
diff mbox series

Patch

diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index 56c4b3f8a01b..e10b90a8917a 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -759,7 +759,7 @@  class DebugfsProvider(Provider):
             if len(vms) == 0:
                 self.do_read = False
 
-            self.paths = filter(lambda x: "{}-".format(pid) in x, vms)
+            self.paths = list(filter(lambda x: "{}-".format(pid) in x, vms))
 
         else:
             self.paths = []
@@ -1219,10 +1219,10 @@  class Tui(object):
         (x, term_width) = self.screen.getmaxyx()
         row = 2
         for line in text:
-            start = (term_width - len(line)) / 2
+            start = (term_width - len(line)) // 2
             self.screen.addstr(row, start, line)
             row += 1
-        self.screen.addstr(row + 1, (term_width - len(hint)) / 2, hint,
+        self.screen.addstr(row + 1, (term_width - len(hint)) // 2, hint,
                            curses.A_STANDOUT)
         self.screen.getkey()