diff options
author | Bastian Bloessl <mail@bastibl.net> | 2019-06-18 09:24:35 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-06-19 13:00:00 -0700 |
commit | cb044a4c4b2c6657876f996617a24a44d1ac3b5d (patch) | |
tree | dd6815d0eb2fc9173f726dc602e994a01e94e418 /gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py | |
parent | 3750f748501ec83d60c489dfa700522f3be21b00 (diff) |
ctrport-monitor: fix error handling
Diffstat (limited to 'gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py')
-rw-r--r-- | gnuradio-runtime/python/gnuradio/ctrlport/GNURadioControlPortClient.py | 55 |
1 files changed, 3 insertions, 52 deletions
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: |