diff options
author | terminaldweller <devi@terminaldweller.com> | 2023-03-23 22:11:12 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2023-03-23 22:11:12 +0000 |
commit | 10a9bc8cb6414eff3e7f50e3b05bde3ae8ff9cef (patch) | |
tree | 5d889b92e96aee7e693c6543e44dcfe78f45dca5 | |
parent | virttop is now an interactive utility (diff) | |
download | virttop-10a9bc8cb6414eff3e7f50e3b05bde3ae8ff9cef.tar.gz virttop-10a9bc8cb6414eff3e7f50e3b05bde3ae8ff9cef.zip |
fixed the main function so poetry build actually works correctly
Diffstat (limited to '')
-rw-r--r-- | pyproject.toml | 2 | ||||
-rwxr-xr-x | virttop/virttop.py | 23 |
2 files changed, 15 insertions, 10 deletions
diff --git a/pyproject.toml b/pyproject.toml index 1f4a7b6..d36c74f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "virttop" -version = "0.2.0" +version = "0.2.1" description = "A top like utility for libvirt" authors = ["terminaldweller <devi@terminaldweller.com>"] license = "GPL-3.0" diff --git a/virttop/virttop.py b/virttop/virttop.py index 99f2b61..47bf53f 100755 --- a/virttop/virttop.py +++ b/virttop/virttop.py @@ -363,8 +363,9 @@ def read_config(config_path) -> ConfigData: return config_data -def curses_init() -> None: +def curses_init(): """Initialize ncurses.""" + stdscr = curses.initscr() curses.start_color() curses.use_default_colors() curses.curs_set(False) @@ -372,6 +373,7 @@ def curses_init() -> None: curses.cbreak() stdscr.keypad(True) curses.halfdelay(4) + return stdscr def init_color_pairs(config_data: ConfigData) -> None: @@ -400,14 +402,14 @@ def get_visible_rows(max_rows: int, sel: int) -> typing.Tuple[int, int]: return win_min_row, win_max_row -async def main() -> None: - """entrypoint""" +async def main_loop() -> None: + """Main TUI loop.""" sel: int = 0 current_row: int = 0 current_visi: int = 0 vm_name_ordered_list: typing.List[str] = [] - curses_init() + stdscr = curses_init() signal.signal(signal.SIGINT, sig_handler_sigint) argparser = Argparser() config_data = read_config(argparser.args.config) @@ -422,7 +424,6 @@ async def main() -> None: request_cred, None, ] - # conn = libvirt.openAuth(hv_host, auth, libvirt.VIR_CONNECT_RO) conn = libvirt.openAuth(hv_host, auth, 0) hosts = conn.listAllDomains() if len(hosts) > 0: @@ -537,12 +538,16 @@ async def main() -> None: stdscr.refresh() -# FIXME- the finally wipes the screen, effectively rendering the help option useless -if __name__ == "__main__": - stdscr = curses.initscr() +def main() -> None: + """Entry point.""" try: - asyncio.run(main()) + asyncio.run(main_loop()) except Exception as e: print(e) finally: do_cleanup() + + +# FIXME- the finally wipes the screen, effectively rendering the help option useless +if __name__ == "__main__": + main() |