From: Kefu Chai Date: Tue, 23 Mar 2021 08:06:45 +0000 (+0800) Subject: pybind/ceph_daemon: do not fail if prettytable is not available X-Git-Tag: v14.2.22~27^2~17^2~2^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=170e71508061ea4a019c6f3b9fa13248d119f151;p=ceph.git pybind/ceph_daemon: do not fail if prettytable is not available ubuntu focal does not package python-prettytable. but we need to run "make check" on focal. it turns out the prettytable is not a must have for running "make check", so just skip it if it is not around. this change is not cherry-picked from master, as we have dropped python2 support in master, and python3-prettytable is packged fro python3 on ubuntu focal. also nautilus is the latest release which has python2 support. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/ceph_daemon.py b/src/pybind/ceph_daemon.py index 9b55613f5d9b..a5876e09946e 100644 --- a/src/pybind/ceph_daemon.py +++ b/src/pybind/ceph_daemon.py @@ -21,7 +21,11 @@ except ImportError: from collections import OrderedDict from fcntl import ioctl from fnmatch import fnmatch -from prettytable import PrettyTable, HEADER +try: + from prettytable import PrettyTable, HEADER +except ImportError: + # only allowed for test + PrettyTable = None from signal import signal, SIGWINCH from termios import TIOCGWINSZ @@ -399,6 +403,9 @@ class DaemonWatcher(object): """ Show all selected stats with section, full name, nick, and prio """ + if PrettyTable is None: + ostr.write('unable to import prettytable\n') + return table = PrettyTable(('section', 'name', 'nick', 'prio')) table.align['section'] = 'l' table.align['name'] = 'l'