Skip to content

Commit d571c52

Browse files
committedSep 5, 2016
artiq_client: fix 'show log', closes #552
1 parent 87fad87 commit d571c52

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed
 

‎artiq/frontend/artiq_client.py

+6-26
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from artiq.protocols.pc_rpc import Client
1515
from artiq.protocols.sync_struct import Subscriber
16+
from artiq.protocols.broadcast import Receiver
1617
from artiq.protocols import pyon
1718
from artiq.tools import short_format
1819

@@ -236,8 +237,6 @@ def _show_datasets(datasets):
236237

237238

238239
def _run_subscriber(host, port, subscriber):
239-
if port is None:
240-
port = 3250
241240
loop = asyncio.get_event_loop()
242241
try:
243242
loop.run_until_complete(subscriber.connect(host, port))
@@ -259,7 +258,8 @@ def init_d(x):
259258
return d
260259
subscriber = Subscriber(notifier_name, init_d,
261260
lambda mod: display_fun(d))
262-
_run_subscriber(args.server, args.port, subscriber)
261+
port = 3250 if args.port is None else args.port
262+
_run_subscriber(args.server, port, subscriber)
263263

264264

265265
def _print_log_record(record):
@@ -268,30 +268,10 @@ def _print_log_record(record):
268268
print(level, source, t, message)
269269

270270

271-
class _LogPrinter:
272-
def __init__(self, init):
273-
for record in init:
274-
_print_log_record(record)
275-
276-
def append(self, record):
277-
_print_log_record(record)
278-
279-
def insert(self, i, record):
280-
_print_log_record(record)
281-
282-
def pop(self, i=-1):
283-
pass
284-
285-
def __delitem__(self, x):
286-
pass
287-
288-
def __setitem__(self, k, v):
289-
pass
290-
291-
292271
def _show_log(args):
293-
subscriber = Subscriber("log", _LogPrinter)
294-
_run_subscriber(args.server, args.port, subscriber)
272+
subscriber = Receiver("log", [_print_log_record])
273+
port = 1067 if args.port is None else args.port
274+
_run_subscriber(args.server, port, subscriber)
295275

296276

297277
def main():

0 commit comments

Comments
 (0)
Please sign in to comment.