mirror of
https://github.com/meshtastic/python.git
synced 2025-12-31 11:57:57 -05:00
Merge pull request #79 from timgunter/tabulate
Switch to using tabulate to print out node database
This commit is contained in:
@@ -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"""
|
||||
|
||||
2
setup.py
2
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"]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user