From 65dc2c83d72c4f72bfff809a23bce0ae7b6b1564 Mon Sep 17 00:00:00 2001 From: Tim Gunter Date: Fri, 26 Mar 2021 08:56:42 -0700 Subject: [PATCH] Switch to using tabulate to print out node database --- meshtastic/__main__.py | 12 ++---------- setup.py | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index d74b470..4b4aee7 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -13,7 +13,7 @@ import traceback import pkg_resources from datetime import datetime import timeago -from easy_table import EasyTable +from tabulate import tabulate """We only import the tunnel code if we are on a platform that can run it""" have_tunnel = platform.system() == 'Linux' @@ -131,14 +131,8 @@ def getTimeAgo(ts, default="N/A"): # Print Nodes - def printNodes(nodes, myId): # Create the table and define the structure - table = EasyTable("Nodes") - table.setCorners("/", "\\", "\\", "/") - table.setOuterStructure("|", "-") - table.setInnerStructure("|", "-", "+") - tableData = [] for node in nodes: if node['user']['id'] == myId: @@ -161,10 +155,8 @@ def printNodes(nodes, myId): RowsOk = sorted(Rows, key=lambda k: k['LastHeard'].startswith("N/A")) for i in range(len(RowsOk)): RowsOk[i]['N'] = i+1 - table.setData(RowsOk) - - table.displayTable() + print(tabulate(RowsOk, headers='keys', tablefmt='fancy_grid')) def setPref(attributes, name, valStr): """Set a channel or preferences value""" diff --git a/setup.py b/setup.py index 218190d..a6844cc 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ setup( include_package_data=True, install_requires=["pyserial>=3.4", "protobuf>=3.13.0", "pypubsub>=4.0.3", "dotmap>=1.3.14", "pexpect>=4.6.0", "pyqrcode>=1.2.1", - "pygatt>=4.0.5", "easy-table==0.0.4", "timeago>=1.0.15"], + "pygatt>=4.0.5", "tabulate>=0.8.9", "timeago>=1.0.15"], extras_require={ 'tunnel': ["pytap2>=2.0.0"] },