artiq_client: fix 'show log', closes #552

This commit is contained in:
Sebastien Bourdeauducq 2016-09-05 15:37:35 +08:00
parent e45c089428
commit 71eb65c527
1 changed files with 6 additions and 26 deletions

View File

@ -13,6 +13,7 @@ from prettytable import PrettyTable
from artiq.protocols.pc_rpc import Client
from artiq.protocols.sync_struct import Subscriber
from artiq.protocols.broadcast import Receiver
from artiq.protocols import pyon
from artiq.tools import short_format
@ -236,8 +237,6 @@ def _show_datasets(datasets):
def _run_subscriber(host, port, subscriber):
if port is None:
port = 3250
loop = asyncio.get_event_loop()
try:
loop.run_until_complete(subscriber.connect(host, port))
@ -259,7 +258,8 @@ def _show_dict(args, notifier_name, display_fun):
return d
subscriber = Subscriber(notifier_name, init_d,
lambda mod: display_fun(d))
_run_subscriber(args.server, args.port, subscriber)
port = 3250 if args.port is None else args.port
_run_subscriber(args.server, port, subscriber)
def _print_log_record(record):
@ -268,30 +268,10 @@ def _print_log_record(record):
print(level, source, t, message)
class _LogPrinter:
def __init__(self, init):
for record in init:
_print_log_record(record)
def append(self, record):
_print_log_record(record)
def insert(self, i, record):
_print_log_record(record)
def pop(self, i=-1):
pass
def __delitem__(self, x):
pass
def __setitem__(self, k, v):
pass
def _show_log(args):
subscriber = Subscriber("log", _LogPrinter)
_run_subscriber(args.server, args.port, subscriber)
subscriber = Receiver("log", [_print_log_record])
port = 1067 if args.port is None else args.port
_run_subscriber(args.server, port, subscriber)
def main():