diff options
author | Tom Rondeau <tom@trondeau.com> | 2015-03-02 13:49:27 -0500 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2015-04-02 15:38:57 -0700 |
commit | a0afbb52d456a93c58a693d52500a200358e6bd3 (patch) | |
tree | b3c26a9e280057229a80b05c2cb5f835b0f9ef5c /gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py | |
parent | 7bdd6effd7b6b36ea8d86cb57329a20874fb3290 (diff) |
controlport: Adds ability to configure Thrift through a config file
Checks GNU Radio's preference files for [ControlPort] config option to point to a file name. That file is the same prefs structure with [Thrift] and key value pairs such as "port = 9090" to set config specific to Thrift.
Diffstat (limited to 'gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py')
-rw-r--r-- | gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py index f086b85834..f662a66c90 100644 --- a/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py +++ b/gnuradio-runtime/python/gnuradio/ctrlport/RPCConnectionThrift.py @@ -26,6 +26,7 @@ from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol from gnuradio.ctrlport.GNURadio import ControlPort from gnuradio.ctrlport import RPCConnection +from gnuradio import gr import sys class ThriftRadioClient: @@ -64,8 +65,19 @@ class RPCConnectionThrift(RPCConnection.RPCConnection): self.BaseTypes = ttypes.BaseTypes self.KnobBase = ttypes.KnobBase + # If not set by the user, get the port number from the thrift + # config file, if one is set. Defaults to 9090 otherwise. if port is None: - port = 9090 + p = gr.prefs() + thrift_config_file = p.get_string("ControlPort", "config", ""); + if(len(thrift_config_file) > 0): + p.add_config_file(thrift_config_file) + port = p.get_long("thrift", "port", 9090) + else: + port = 9090 + else: + port = int(port) + super(RPCConnectionThrift, self).__init__(method='thrift', port=port, host=host) self.newConnection(host, port) |