qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 27/34] scripts/kvm/kvm_stat: Make tui function a


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 27/34] scripts/kvm/kvm_stat: Make tui function a class
Date: Thu, 7 Jan 2016 16:40:35 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0


On 10/12/2015 13:12, Janosch Frank wrote:
> +
> +def tui(screen, stats):
> +    interface = Tui(screen, stats)
> +    interface.show_stats()
>  

I think it would make sense to "reimplement" curses.wrapper as
__enter__/__exit__ methods in Tui(), and then use with here.

It's really just a bunch of curses calls:

        self.stdscr = curses.initscr()
        curses.noecho()
        curses.cbreak()

        # Start color, too.  Harmless if the terminal doesn't have
        # color; user can test with has_color() later on.  The try/catch
        # works around a minor bit of over-conscientiousness in the curses
        # module -- the error return from C start_color() is ignorable.
        try:
            curses.start_color()
        except:
            pass

        curses.use_default_colors()
---

        # Set everything back to normal
        if self.stdscr:
            self.stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin()

where the existing calls to curses.use_default_colors and curses.noecho
can then be removed.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]