]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/ceph_daemon: do not fail if prettytable is not available 40335/head
authorKefu Chai <kchai@redhat.com>
Tue, 23 Mar 2021 08:06:45 +0000 (16:06 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 23 Mar 2021 08:06:46 +0000 (16:06 +0800)
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 <kchai@redhat.com>
src/pybind/ceph_daemon.py

index 9b55613f5d9b090340783848c82b80a19295c545..a5876e09946e5fa09090f6bb9f1f71a1ebbbcc88 100644 (file)
@@ -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'