From d571c528000436c3e1f40832897637ee9bd0f300 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 5 Sep 2016 15:37:35 +0800 Subject: [PATCH] artiq_client: fix 'show log', closes #552 --- artiq/frontend/artiq_client.py | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/artiq/frontend/artiq_client.py b/artiq/frontend/artiq_client.py index e6884cf29..28a21ac49 100755 --- a/artiq/frontend/artiq_client.py +++ b/artiq/frontend/artiq_client.py @@ -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():