From cb044a4c4b2c6657876f996617a24a44d1ac3b5d Mon Sep 17 00:00:00 2001 From: Bastian Bloessl <mail@bastibl.net> Date: Tue, 18 Jun 2019 09:24:35 +0200 Subject: ctrport-monitor: fix error handling --- .../gnuradio/ctrlport/GNURadioControlPortClient.py | 55 ++-------------------- 1 file changed, 3 insertions(+), 52 deletions(-) (limited to 'gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py') diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py b/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py index bee5cd15ed..46ef3cbbae 100644 --- a/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py +++ b/gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py @@ -30,14 +30,12 @@ is currently the only supported transport. from __future__ import print_function from __future__ import unicode_literals -from argparse import ArgumentParser - from gnuradio.ctrlport.RPCConnection import RPCMethods try: from gnuradio.ctrlport.RPCConnectionThrift import RPCConnectionThrift from thrift.transport.TTransport import TTransportException except ImportError: - # Thrift support not provided we should remove it from RPCMethods + print("ControlPort requires Thrift, but it was not found!") pass @@ -45,8 +43,6 @@ except ImportError: GNURadioControlPortClient is the main class for creating a GNU Radio ControlPort client application for all transports. -Two constructors are provided for creating a connection to ControlPort. - """ class GNURadioControlPortClient(object): @@ -79,61 +75,16 @@ class GNURadioControlPortClient(object): such as QtGui.QApplication.exec_ """ - - def __init__(self, host = None, port = None, rpcmethod = 'thrift', callback = None, blockingcallback = None): - __init__([host, port], rpcmethod, callback, blockingcallback) - - """ - Constructor for creating a ControlPort from a tuple of command line arguments (i.e. sys.argv) - - Args: - argv: List of command line arguments. Future implementations may parse the argument list - for OptionParser style key / value pairs, however the current implementation - simply takes argv[1] and argv[2] as the connection hostname and port, respectively. - - Example Usage: - - In the following QT client example, the ControlPort host and port are specified to - the Client application as the first two command line arguments. The MAINWindow class is - of the type QtGui.QMainWindow, and is the main window for the QT application. MyApp - is a simple helper class for starting the application. - - class MAINWindow(QtGui.QMainWindow): - ... QT Application implementation ... - - class MyApp(object): - def __init__(self, args): - from GNURadioControlPortClient import GNURadioControlPortClient - GNURadioControlPortClient(args, 'thrift', self.run, QtGui.QApplication(sys.argv).exec_) - - def run(self, client): - MAINWindow(client).show() - - MyApp(sys.argv) - - - """ - - def __init__(self, argv = [], rpcmethod = 'thrift', callback = None, blockingcallback = None): - - parser = ArgumentParser(description="GNU Radio Control Port Monitor") - parser.add_argument("host", nargs="?", default="localhost", help="host name or IP") - parser.add_argument("port", help="port") - args = parser.parse_args() - + def __init__(self, host=None, port=None, rpcmethod='thrift', callback=None, blockingcallback=None): self.client = None if rpcmethod in RPCMethods: if rpcmethod == 'thrift': - #print("making RPCConnectionThrift") - self.client = RPCConnectionThrift(args.host, args.port) - #print("made %s" % self.client) + self.client = RPCConnectionThrift(host, port) - #print("making callback call") if not callback is None: callback(self.client) - #print("making blockingcallback call") if not blockingcallback is None: blockingcallback() else: -- cgit v1.2.3