diff options
-rw-r--r-- | grc/CMakeLists.txt | 7 | ||||
-rw-r--r-- | grc/__main__.py | 20 | ||||
-rwxr-xr-x | grc/checks.py | 80 | ||||
-rw-r--r-- | grc/core/CMakeLists.txt | 28 | ||||
-rw-r--r-- | grc/core/generator/CMakeLists.txt | 10 | ||||
-rw-r--r-- | grc/core/utils/CMakeLists.txt | 11 | ||||
-rw-r--r-- | grc/examples/CMakeLists.txt | 37 | ||||
-rw-r--r-- | grc/examples/simple/variable_config.grc | 561 | ||||
-rw-r--r-- | grc/examples/xmlrpc/readme.txt | 18 | ||||
-rw-r--r-- | grc/examples/xmlrpc/xmlrpc_client.grc | 428 | ||||
-rw-r--r-- | grc/examples/xmlrpc/xmlrpc_client_script.py | 23 | ||||
-rw-r--r-- | grc/examples/xmlrpc/xmlrpc_server.grc | 908 | ||||
-rw-r--r-- | grc/gui/ActionHandler.py | 2 | ||||
-rw-r--r-- | grc/gui/CMakeLists.txt | 34 | ||||
-rwxr-xr-x | grc/main.py | 55 | ||||
-rwxr-xr-x | grc/scripts/gnuradio-companion | 129 |
16 files changed, 195 insertions, 2156 deletions
diff --git a/grc/CMakeLists.txt b/grc/CMakeLists.txt index a764e3dc4d..4c782a7f7d 100644 --- a/grc/CMakeLists.txt +++ b/grc/CMakeLists.txt @@ -96,8 +96,10 @@ install( COMPONENT "grc" ) +file(GLOB py_files "*.py") + GR_PYTHON_INSTALL( - FILES __init__.py + FILES ${py_files} DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc COMPONENT "grc" ) @@ -135,8 +137,7 @@ endif(WIN32) ######################################################################## add_subdirectory(blocks) add_subdirectory(gui) -add_subdirectory(python) +add_subdirectory(core) add_subdirectory(scripts) -add_subdirectory(examples) endif(ENABLE_GRC) diff --git a/grc/__main__.py b/grc/__main__.py new file mode 100644 index 0000000000..899d0195d1 --- /dev/null +++ b/grc/__main__.py @@ -0,0 +1,20 @@ +# Copyright 2016 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +from .main import main + +main() diff --git a/grc/checks.py b/grc/checks.py new file mode 100755 index 0000000000..fd0e5de06a --- /dev/null +++ b/grc/checks.py @@ -0,0 +1,80 @@ +# Copyright 2009-2016 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +import os +import warnings + + +GR_IMPORT_ERROR_MESSAGE = """\ +Cannot import gnuradio. + +Is the model path environment variable set correctly? + All OS: PYTHONPATH + +Is the library path environment variable set correctly? + Linux: LD_LIBRARY_PATH + Windows: PATH + MacOSX: DYLD_LIBRARY_PATH +""" + + +def die(error, message): + msg = "{0}\n\n({1})".format(message, error) + try: + import gtk + d = gtk.MessageDialog( + type=gtk.MESSAGE_ERROR, + buttons=gtk.BUTTONS_CLOSE, + message_format=msg, + ) + d.set_title(type(error).__name__) + d.run() + exit(1) + except ImportError: + exit(type(error).__name__ + '\n\n' + msg) + + +def check_gtk(): + try: + warnings.filterwarnings("error") + import pygtk + pygtk.require('2.0') + import gtk + gtk.init_check() + warnings.filterwarnings("always") + except Exception as err: + die(err, "Failed to initialize GTK. If you are running over ssh, " + "did you enable X forwarding and start ssh with -X?") + + +def check_gnuradio_import(): + try: + from gnuradio import gr + except ImportError as err: + die(err, GR_IMPORT_ERROR_MESSAGE) + + +def check_blocks_path(): + if 'GR_DONT_LOAD_PREFS' in os.environ and not os.environ.get('GRC_BLOCKS_PATH', ''): + die(EnvironmentError("No block definitions available"), + "Can't find block definitions. Use config.conf or GRC_BLOCKS_PATH.") + + +def do_all(): + check_gnuradio_import() + check_gtk() + check_blocks_path() diff --git a/grc/core/CMakeLists.txt b/grc/core/CMakeLists.txt index 8aee8116b2..51b0dacba6 100644 --- a/grc/core/CMakeLists.txt +++ b/grc/core/CMakeLists.txt @@ -17,30 +17,18 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -######################################################################## -GR_PYTHON_INSTALL(FILES - Block.py - Config.py - Connection.py - Constants.py - Element.py - FlowGraph.py - __init__.py - odict.py - Param.py - ParseXML.py - Platform.py - Port.py +file(GLOB py_files "*.py") + +GR_PYTHON_INSTALL( + FILES ${py_files} DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core COMPONENT "grc" ) -install(FILES - block.dtd - block_tree.dtd - default_flow_graph.grc - domain.dtd - flow_graph.dtd +file(GLOB dtd_files "*.dtd") + +install( + FILES ${dtd_files} default_flow_graph.grc DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core COMPONENT "grc" ) diff --git a/grc/core/generator/CMakeLists.txt b/grc/core/generator/CMakeLists.txt index c129d6051c..4bdd59a7a2 100644 --- a/grc/core/generator/CMakeLists.txt +++ b/grc/core/generator/CMakeLists.txt @@ -17,10 +17,10 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -######################################################################## -GR_PYTHON_INSTALL(FILES - __init__.py - Generator.py +file(GLOB py_files "*.py") + +GR_PYTHON_INSTALL( + FILES ${py_files} DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core/generator COMPONENT "grc" ) @@ -30,5 +30,3 @@ install(FILES DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core/generator COMPONENT "grc" ) - -add_subdirectory(utils) diff --git a/grc/core/utils/CMakeLists.txt b/grc/core/utils/CMakeLists.txt index fbbfbf6499..2528fbc43c 100644 --- a/grc/core/utils/CMakeLists.txt +++ b/grc/core/utils/CMakeLists.txt @@ -17,13 +17,10 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -######################################################################## -GR_PYTHON_INSTALL(FILES - complexity.py - epy_block_io.py - expr_utils.py - extract_docs.py - __init__.py +file(GLOB py_files "*.py") + +GR_PYTHON_INSTALL( + FILES ${py_files} DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/core/utils COMPONENT "grc" ) diff --git a/grc/examples/CMakeLists.txt b/grc/examples/CMakeLists.txt deleted file mode 100644 index a218dbe500..0000000000 --- a/grc/examples/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. - -# SIMPLE -install( - FILES - simple/variable_config.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/grc/simple - COMPONENT "grc" -) - -# XMLRPC -install( - FILES - xmlrpc/readme.txt - xmlrpc/xmlrpc_client.grc - xmlrpc/xmlrpc_client_script.py - xmlrpc/xmlrpc_server.grc - DESTINATION ${GR_PKG_DATA_DIR}/examples/grc/xmlrpc - COMPONENT "grc" -) diff --git a/grc/examples/simple/variable_config.grc b/grc/examples/simple/variable_config.grc deleted file mode 100644 index 0b60abc813..0000000000 --- a/grc/examples/simple/variable_config.grc +++ /dev/null @@ -1,561 +0,0 @@ -<?xml version='1.0' encoding='ASCII'?> -<flow_graph> - <timestamp>Sat Jul 12 16:15:51 2014</timestamp> - <block> - <key>options</key> - <param> - <key>id</key> - <value>variable_config_demo</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value>Variable Config Block Demonstration</value> - </param> - <param> - <key>author</key> - <value>Example</value> - </param> - <param> - <key>description</key> - <value>Save/Load freq from a config file.</value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> - </param> - <param> - <key>generate_options</key> - <value>qt_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(-1, 2)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>samp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>32000</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(-1, 125)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>analog_sig_source_x</key> - <param> - <key>id</key> - <value>analog_sig_source_x_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>samp_rate</key> - <value>samp_rate</value> - </param> - <param> - <key>waveform</key> - <value>analog.GR_COS_WAVE</value> - </param> - <param> - <key>freq</key> - <value>freq</value> - </param> - <param> - <key>amp</key> - <value>1</value> - </param> - <param> - <key>offset</key> - <value>0</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>_coordinate</key> - <value>(173, 201)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blocks_throttle</key> - <param> - <key>id</key> - <value>blocks_throttle_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>ignoretag</key> - <value>True</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>_coordinate</key> - <value>(392, 233)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>qtgui_freq_sink_x</key> - <param> - <key>id</key> - <value>qtgui_freq_sink_x_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>name</key> - <value>QT GUI Plot</value> - </param> - <param> - <key>fftsize</key> - <value>1024</value> - </param> - <param> - <key>wintype</key> - <value>firdes.WIN_BLACKMAN_hARRIS</value> - </param> - <param> - <key>fc</key> - <value>0</value> - </param> - <param> - <key>bw</key> - <value>samp_rate</value> - </param> - <param> - <key>autoscale</key> - <value>False</value> - </param> - <param> - <key>average</key> - <value>1.0</value> - </param> - <param> - <key>ymin</key> - <value>-140</value> - </param> - <param> - <key>ymax</key> - <value>10</value> - </param> - <param> - <key>nconnections</key> - <value>1</value> - </param> - <param> - <key>update_time</key> - <value>0.10</value> - </param> - <param> - <key>gui_hint</key> - <value></value> - </param> - <param> - <key>label1</key> - <value></value> - </param> - <param> - <key>width1</key> - <value>1</value> - </param> - <param> - <key>color1</key> - <value>"blue"</value> - </param> - <param> - <key>alpha1</key> - <value>1.0</value> - </param> - <param> - <key>label2</key> - <value></value> - </param> - <param> - <key>width2</key> - <value>1</value> - </param> - <param> - <key>color2</key> - <value>"red"</value> - </param> - <param> - <key>alpha2</key> - <value>1.0</value> - </param> - <param> - <key>label3</key> - <value></value> - </param> - <param> - <key>width3</key> - <value>1</value> - </param> - <param> - <key>color3</key> - <value>"green"</value> - </param> - <param> - <key>alpha3</key> - <value>1.0</value> - </param> - <param> - <key>label4</key> - <value></value> - </param> - <param> - <key>width4</key> - <value>1</value> - </param> - <param> - <key>color4</key> - <value>"black"</value> - </param> - <param> - <key>alpha4</key> - <value>1.0</value> - </param> - <param> - <key>label5</key> - <value></value> - </param> - <param> - <key>width5</key> - <value>1</value> - </param> - <param> - <key>color5</key> - <value>"cyan"</value> - </param> - <param> - <key>alpha5</key> - <value>1.0</value> - </param> - <param> - <key>label6</key> - <value></value> - </param> - <param> - <key>width6</key> - <value>1</value> - </param> - <param> - <key>color6</key> - <value>"magenta"</value> - </param> - <param> - <key>alpha6</key> - <value>1.0</value> - </param> - <param> - <key>label7</key> - <value></value> - </param> - <param> - <key>width7</key> - <value>1</value> - </param> - <param> - <key>color7</key> - <value>"yellow"</value> - </param> - <param> - <key>alpha7</key> - <value>1.0</value> - </param> - <param> - <key>label8</key> - <value></value> - </param> - <param> - <key>width8</key> - <value>1</value> - </param> - <param> - <key>color8</key> - <value>"dark red"</value> - </param> - <param> - <key>alpha8</key> - <value>1.0</value> - </param> - <param> - <key>label9</key> - <value></value> - </param> - <param> - <key>width9</key> - <value>1</value> - </param> - <param> - <key>color9</key> - <value>"dark green"</value> - </param> - <param> - <key>alpha9</key> - <value>1.0</value> - </param> - <param> - <key>label10</key> - <value></value> - </param> - <param> - <key>width10</key> - <value>1</value> - </param> - <param> - <key>color10</key> - <value>"dark blue"</value> - </param> - <param> - <key>alpha10</key> - <value>1.0</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(643, 221)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_qtgui_range</key> - <param> - <key>id</key> - <value>freq</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Frequency (Hz)</value> - </param> - <param> - <key>value</key> - <value>1e3</value> - </param> - <param> - <key>start</key> - <value>-samp_rate/2</value> - </param> - <param> - <key>stop</key> - <value>samp_rate/2</value> - </param> - <param> - <key>step</key> - <value>1</value> - </param> - <param> - <key>widget</key> - <value>counter_slider</value> - </param> - <param> - <key>orient</key> - <value>Qt.Horizontal</value> - </param> - <param> - <key>min_len</key> - <value>200</value> - </param> - <param> - <key>gui_hint</key> - <value></value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(339, 9)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>freq_init</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>1000</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>/home/mbant/.gnuradio/config.conf</value> - </param> - <param> - <key>section</key> - <value>main</value> - </param> - <param> - <key>option</key> - <value>freq</value> - </param> - <param> - <key>writeback</key> - <value>freq</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(168, 0)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <connection> - <source_block_id>analog_sig_source_x_0</source_block_id> - <sink_block_id>blocks_throttle_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>qtgui_freq_sink_x_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> -</flow_graph> diff --git a/grc/examples/xmlrpc/readme.txt b/grc/examples/xmlrpc/readme.txt deleted file mode 100644 index 056ad1e823..0000000000 --- a/grc/examples/xmlrpc/readme.txt +++ /dev/null @@ -1,18 +0,0 @@ -################################################## -# XMLRPC example -################################################## - -XMLRPC allows software to make remote function calls over http. -In the case of GRC, one can use XMLRPC to modify variables in a running flow graph. -See http://www.xmlrpc.com/ - ---- Server Example --- -Place an "XMLRPC Server" block inside of any flow graph. -The server will provide set functions for every variable in the flow graph. -If a variable is called "freq", the server will provide a function set_freq(new_freq). -Run the server example and experiment with the example client script. - --- Client Example -- -The "XMLRPC Client" block will give a variable control over one remove function. -In the example client, there is one client block and gui control per variable. -This technique can be used to remotely control a flow graph, perhaps running on a non-gui machine. diff --git a/grc/examples/xmlrpc/xmlrpc_client.grc b/grc/examples/xmlrpc/xmlrpc_client.grc deleted file mode 100644 index 45d8af2824..0000000000 --- a/grc/examples/xmlrpc/xmlrpc_client.grc +++ /dev/null @@ -1,428 +0,0 @@ -<?xml version='1.0' encoding='ASCII'?> -<flow_graph> - <timestamp>Sat Jul 12 17:10:55 2014</timestamp> - <block> - <key>options</key> - <param> - <key>id</key> - <value>client_block</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value>XMLRPC Client</value> - </param> - <param> - <key>author</key> - <value>Example</value> - </param> - <param> - <key>description</key> - <value>example flow graph</value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> - </param> - <param> - <key>generate_options</key> - <value>qt_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(-2, 0)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>samp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>32000</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(13, 172)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>xmlrpc_client</key> - <param> - <key>id</key> - <value>xmlrpc_client</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>addr</key> - <value>localhost</value> - </param> - <param> - <key>port</key> - <value>1234</value> - </param> - <param> - <key>callback</key> - <value>set_freq</value> - </param> - <param> - <key>variable</key> - <value>freq</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(177, 0)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>xmlrpc_client</key> - <param> - <key>id</key> - <value>xmlrpc_client0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>addr</key> - <value>localhost</value> - </param> - <param> - <key>port</key> - <value>1234</value> - </param> - <param> - <key>callback</key> - <value>set_ampl</value> - </param> - <param> - <key>variable</key> - <value>ampl</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(308, 0)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>xmlrpc_client</key> - <param> - <key>id</key> - <value>xmlrpc_client1</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>addr</key> - <value>localhost</value> - </param> - <param> - <key>port</key> - <value>1234</value> - </param> - <param> - <key>callback</key> - <value>set_offset</value> - </param> - <param> - <key>variable</key> - <value>offset*ampl</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(440, 4)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_qtgui_range</key> - <param> - <key>id</key> - <value>freq</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Frequency (Hz)</value> - </param> - <param> - <key>value</key> - <value>1000</value> - </param> - <param> - <key>start</key> - <value>0</value> - </param> - <param> - <key>stop</key> - <value>5e3</value> - </param> - <param> - <key>step</key> - <value>1</value> - </param> - <param> - <key>widget</key> - <value>counter_slider</value> - </param> - <param> - <key>orient</key> - <value>Qt.Horizontal</value> - </param> - <param> - <key>min_len</key> - <value>200</value> - </param> - <param> - <key>gui_hint</key> - <value>0,0,1,2</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(209, 165)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_qtgui_range</key> - <param> - <key>id</key> - <value>ampl</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Amplitude</value> - </param> - <param> - <key>value</key> - <value>1</value> - </param> - <param> - <key>start</key> - <value>0</value> - </param> - <param> - <key>stop</key> - <value>2</value> - </param> - <param> - <key>step</key> - <value>.1</value> - </param> - <param> - <key>widget</key> - <value>counter_slider</value> - </param> - <param> - <key>orient</key> - <value>Qt.Horizontal</value> - </param> - <param> - <key>min_len</key> - <value>200</value> - </param> - <param> - <key>gui_hint</key> - <value>1,0,1,2</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(367, 158)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_qtgui_chooser</key> - <param> - <key>id</key> - <value>offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>Offset</value> - </param> - <param> - <key>type</key> - <value>int</value> - </param> - <param> - <key>num_opts</key> - <value>3</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>options</key> - <value>[0, 1, 2]</value> - </param> - <param> - <key>labels</key> - <value>[]</value> - </param> - <param> - <key>option0</key> - <value>-1</value> - </param> - <param> - <key>label0</key> - <value>neg</value> - </param> - <param> - <key>option1</key> - <value>0</value> - </param> - <param> - <key>label1</key> - <value>zero</value> - </param> - <param> - <key>option2</key> - <value>1</value> - </param> - <param> - <key>label2</key> - <value>pos</value> - </param> - <param> - <key>option3</key> - <value>3</value> - </param> - <param> - <key>label3</key> - <value></value> - </param> - <param> - <key>option4</key> - <value>4</value> - </param> - <param> - <key>label4</key> - <value></value> - </param> - <param> - <key>widget</key> - <value>combo_box</value> - </param> - <param> - <key>orient</key> - <value>Qt.QVBoxLayout</value> - </param> - <param> - <key>gui_hint</key> - <value>2,0,1,2</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(531, 145)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> -</flow_graph> diff --git a/grc/examples/xmlrpc/xmlrpc_client_script.py b/grc/examples/xmlrpc/xmlrpc_client_script.py deleted file mode 100644 index e96c4cbf83..0000000000 --- a/grc/examples/xmlrpc/xmlrpc_client_script.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -import time -import random -import xmlrpclib - -#create server object -s = xmlrpclib.Server("http://localhost:1234") - -#randomly change parameters of the sinusoid -for i in range(10): - #generate random values - new_freq = random.uniform(0, 5000) - new_ampl = random.uniform(0, 2) - new_offset = random.uniform(-1, 1) - #set new values - time.sleep(1) - s.set_freq(new_freq) - time.sleep(1) - s.set_ampl(new_ampl) - time.sleep(1) - s.set_offset(new_offset) - diff --git a/grc/examples/xmlrpc/xmlrpc_server.grc b/grc/examples/xmlrpc/xmlrpc_server.grc deleted file mode 100644 index d210b2694e..0000000000 --- a/grc/examples/xmlrpc/xmlrpc_server.grc +++ /dev/null @@ -1,908 +0,0 @@ -<?xml version='1.0' encoding='ASCII'?> -<flow_graph> - <timestamp>Sat Jul 12 17:11:40 2014</timestamp> - <block> - <key>options</key> - <param> - <key>id</key> - <value>server_block</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value>XMLRPC Server</value> - </param> - <param> - <key>author</key> - <value>Example</value> - </param> - <param> - <key>description</key> - <value>example flow graph</value> - </param> - <param> - <key>window_size</key> - <value>1280, 1024</value> - </param> - <param> - <key>generate_options</key> - <value>qt_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>prompt</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>max_nouts</key> - <value>0</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(0, -1)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>ampl</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>1</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(4, 291)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>freq</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>1000</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(2, 213)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>samp_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>32000</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(2, 136)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(3, 366)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>analog_sig_source_x</key> - <param> - <key>id</key> - <value>analog_sig_source_x_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>samp_rate</key> - <value>samp_rate</value> - </param> - <param> - <key>waveform</key> - <value>analog.GR_COS_WAVE</value> - </param> - <param> - <key>freq</key> - <value>freq</value> - </param> - <param> - <key>amp</key> - <value>ampl</value> - </param> - <param> - <key>offset</key> - <value>offset</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>_coordinate</key> - <value>(175, 0)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>blocks_throttle</key> - <param> - <key>id</key> - <value>blocks_throttle</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>samples_per_second</key> - <value>samp_rate</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>ignoretag</key> - <value>True</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>_coordinate</key> - <value>(399, 35)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>xmlrpc_server</key> - <param> - <key>id</key> - <value>xmlrpc_server</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>addr</key> - <value>localhost</value> - </param> - <param> - <key>port</key> - <value>1234</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(129, 137)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>qtgui_time_sink_x</key> - <param> - <key>id</key> - <value>qtgui_time_sink_x_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>name</key> - <value>Scope Plot</value> - </param> - <param> - <key>size</key> - <value>1024</value> - </param> - <param> - <key>srate</key> - <value>samp_rate</value> - </param> - <param> - <key>autoscale</key> - <value>False</value> - </param> - <param> - <key>ymin</key> - <value>-1</value> - </param> - <param> - <key>ymax</key> - <value>1</value> - </param> - <param> - <key>nconnections</key> - <value>1</value> - </param> - <param> - <key>update_time</key> - <value>0.10</value> - </param> - <param> - <key>entags</key> - <value>True</value> - </param> - <param> - <key>gui_hint</key> - <value>0, 0, 2, 4</value> - </param> - <param> - <key>tr_mode</key> - <value>qtgui.TRIG_MODE_FREE</value> - </param> - <param> - <key>tr_slope</key> - <value>qtgui.TRIG_SLOPE_POS</value> - </param> - <param> - <key>tr_level</key> - <value>0.0</value> - </param> - <param> - <key>tr_delay</key> - <value>0</value> - </param> - <param> - <key>tr_chan</key> - <value>0</value> - </param> - <param> - <key>tr_tag</key> - <value>""</value> - </param> - <param> - <key>label1</key> - <value></value> - </param> - <param> - <key>width1</key> - <value>1</value> - </param> - <param> - <key>color1</key> - <value>"blue"</value> - </param> - <param> - <key>style1</key> - <value>1</value> - </param> - <param> - <key>marker1</key> - <value>-1</value> - </param> - <param> - <key>alpha1</key> - <value>1.0</value> - </param> - <param> - <key>label2</key> - <value></value> - </param> - <param> - <key>width2</key> - <value>1</value> - </param> - <param> - <key>color2</key> - <value>"red"</value> - </param> - <param> - <key>style2</key> - <value>1</value> - </param> - <param> - <key>marker2</key> - <value>-1</value> - </param> - <param> - <key>alpha2</key> - <value>1.0</value> - </param> - <param> - <key>label3</key> - <value></value> - </param> - <param> - <key>width3</key> - <value>1</value> - </param> - <param> - <key>color3</key> - <value>"green"</value> - </param> - <param> - <key>style3</key> - <value>1</value> - </param> - <param> - <key>marker3</key> - <value>-1</value> - </param> - <param> - <key>alpha3</key> - <value>1.0</value> - </param> - <param> - <key>label4</key> - <value></value> - </param> - <param> - <key>width4</key> - <value>1</value> - </param> - <param> - <key>color4</key> - <value>"black"</value> - </param> - <param> - <key>style4</key> - <value>1</value> - </param> - <param> - <key>marker4</key> - <value>-1</value> - </param> - <param> - <key>alpha4</key> - <value>1.0</value> - </param> - <param> - <key>label5</key> - <value></value> - </param> - <param> - <key>width5</key> - <value>1</value> - </param> - <param> - <key>color5</key> - <value>"cyan"</value> - </param> - <param> - <key>style5</key> - <value>1</value> - </param> - <param> - <key>marker5</key> - <value>-1</value> - </param> - <param> - <key>alpha5</key> - <value>1.0</value> - </param> - <param> - <key>label6</key> - <value></value> - </param> - <param> - <key>width6</key> - <value>1</value> - </param> - <param> - <key>color6</key> - <value>"magenta"</value> - </param> - <param> - <key>style6</key> - <value>1</value> - </param> - <param> - <key>marker6</key> - <value>-1</value> - </param> - <param> - <key>alpha6</key> - <value>1.0</value> - </param> - <param> - <key>label7</key> - <value></value> - </param> - <param> - <key>width7</key> - <value>1</value> - </param> - <param> - <key>color7</key> - <value>"yellow"</value> - </param> - <param> - <key>style7</key> - <value>1</value> - </param> - <param> - <key>marker7</key> - <value>-1</value> - </param> - <param> - <key>alpha7</key> - <value>1.0</value> - </param> - <param> - <key>label8</key> - <value></value> - </param> - <param> - <key>width8</key> - <value>1</value> - </param> - <param> - <key>color8</key> - <value>"dark red"</value> - </param> - <param> - <key>style8</key> - <value>1</value> - </param> - <param> - <key>marker8</key> - <value>-1</value> - </param> - <param> - <key>alpha8</key> - <value>1.0</value> - </param> - <param> - <key>label9</key> - <value></value> - </param> - <param> - <key>width9</key> - <value>1</value> - </param> - <param> - <key>color9</key> - <value>"dark green"</value> - </param> - <param> - <key>style9</key> - <value>1</value> - </param> - <param> - <key>marker9</key> - <value>-1</value> - </param> - <param> - <key>alpha9</key> - <value>1.0</value> - </param> - <param> - <key>label10</key> - <value></value> - </param> - <param> - <key>width10</key> - <value>1</value> - </param> - <param> - <key>color10</key> - <value>"blue"</value> - </param> - <param> - <key>style10</key> - <value>1</value> - </param> - <param> - <key>marker10</key> - <value>-1</value> - </param> - <param> - <key>alpha10</key> - <value>1.0</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(644, 13)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>qtgui_freq_sink_x</key> - <param> - <key>id</key> - <value>qtgui_freq_sink_x_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>name</key> - <value>Spectrum Plot</value> - </param> - <param> - <key>fftsize</key> - <value>1024</value> - </param> - <param> - <key>wintype</key> - <value>firdes.WIN_BLACKMAN_hARRIS</value> - </param> - <param> - <key>fc</key> - <value>0</value> - </param> - <param> - <key>bw</key> - <value>samp_rate</value> - </param> - <param> - <key>autoscale</key> - <value>False</value> - </param> - <param> - <key>average</key> - <value>1.0</value> - </param> - <param> - <key>ymin</key> - <value>-140</value> - </param> - <param> - <key>ymax</key> - <value>10</value> - </param> - <param> - <key>nconnections</key> - <value>1</value> - </param> - <param> - <key>update_time</key> - <value>0.10</value> - </param> - <param> - <key>gui_hint</key> - <value>2, 0, 2, 4</value> - </param> - <param> - <key>label1</key> - <value></value> - </param> - <param> - <key>width1</key> - <value>1</value> - </param> - <param> - <key>color1</key> - <value>"blue"</value> - </param> - <param> - <key>alpha1</key> - <value>1.0</value> - </param> - <param> - <key>label2</key> - <value></value> - </param> - <param> - <key>width2</key> - <value>1</value> - </param> - <param> - <key>color2</key> - <value>"red"</value> - </param> - <param> - <key>alpha2</key> - <value>1.0</value> - </param> - <param> - <key>label3</key> - <value></value> - </param> - <param> - <key>width3</key> - <value>1</value> - </param> - <param> - <key>color3</key> - <value>"green"</value> - </param> - <param> - <key>alpha3</key> - <value>1.0</value> - </param> - <param> - <key>label4</key> - <value></value> - </param> - <param> - <key>width4</key> - <value>1</value> - </param> - <param> - <key>color4</key> - <value>"black"</value> - </param> - <param> - <key>alpha4</key> - <value>1.0</value> - </param> - <param> - <key>label5</key> - <value></value> - </param> - <param> - <key>width5</key> - <value>1</value> - </param> - <param> - <key>color5</key> - <value>"cyan"</value> - </param> - <param> - <key>alpha5</key> - <value>1.0</value> - </param> - <param> - <key>label6</key> - <value></value> - </param> - <param> - <key>width6</key> - <value>1</value> - </param> - <param> - <key>color6</key> - <value>"magenta"</value> - </param> - <param> - <key>alpha6</key> - <value>1.0</value> - </param> - <param> - <key>label7</key> - <value></value> - </param> - <param> - <key>width7</key> - <value>1</value> - </param> - <param> - <key>color7</key> - <value>"yellow"</value> - </param> - <param> - <key>alpha7</key> - <value>1.0</value> - </param> - <param> - <key>label8</key> - <value></value> - </param> - <param> - <key>width8</key> - <value>1</value> - </param> - <param> - <key>color8</key> - <value>"dark red"</value> - </param> - <param> - <key>alpha8</key> - <value>1.0</value> - </param> - <param> - <key>label9</key> - <value></value> - </param> - <param> - <key>width9</key> - <value>1</value> - </param> - <param> - <key>color9</key> - <value>"dark green"</value> - </param> - <param> - <key>alpha9</key> - <value>1.0</value> - </param> - <param> - <key>label10</key> - <value></value> - </param> - <param> - <key>width10</key> - <value>1</value> - </param> - <param> - <key>color10</key> - <value>"dark blue"</value> - </param> - <param> - <key>alpha10</key> - <value>1.0</value> - </param> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(644, 126)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <connection> - <source_block_id>analog_sig_source_x_0</source_block_id> - <sink_block_id>blocks_throttle</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_throttle</source_block_id> - <sink_block_id>qtgui_time_sink_x_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_throttle</source_block_id> - <sink_block_id>qtgui_freq_sink_x_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> -</flow_graph> diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py index 37514c9867..077786d4b4 100644 --- a/grc/gui/ActionHandler.py +++ b/grc/gui/ActionHandler.py @@ -69,8 +69,6 @@ class ActionHandler: #initialize self.init_file_paths = file_paths Actions.APPLICATION_INITIALIZE() - #enter the mainloop - gtk.main() def _handle_key_press(self, widget, event): """ diff --git a/grc/gui/CMakeLists.txt b/grc/gui/CMakeLists.txt index e9c4f71e69..aa9592b351 100644 --- a/grc/gui/CMakeLists.txt +++ b/grc/gui/CMakeLists.txt @@ -17,36 +17,10 @@ # the Free Software Foundation, Inc., 51 Franklin Street, # Boston, MA 02110-1301, USA. -######################################################################## -GR_PYTHON_INSTALL(FILES - external_editor.py - Block.py - Colors.py - Config.py - Constants.py - Connection.py - Element.py - Executor.py - FlowGraph.py - Param.py - Platform.py - Port.py - Utils.py - ActionHandler.py - Actions.py - Bars.py - BlockTreeWindow.py - Dialogs.py - DrawingArea.py - FileDialogs.py - MainWindow.py - Messages.py - NotebookPage.py - ParserErrorsDialog.py - PropsDialog.py - Preferences.py - StateCache.py - __init__.py +file(GLOB py_files "*.py") + +GR_PYTHON_INSTALL( + FILES ${py_files} DESTINATION ${GR_PYTHON_DIR}/gnuradio/grc/gui COMPONENT "grc" ) diff --git a/grc/main.py b/grc/main.py new file mode 100755 index 0000000000..ae7a0ce115 --- /dev/null +++ b/grc/main.py @@ -0,0 +1,55 @@ +# Copyright 2009-2016 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +import optparse + +import gtk +from gnuradio import gr + +from .gui.Platform import Platform +from .gui.ActionHandler import ActionHandler + + +VERSION_AND_DISCLAIMER_TEMPLATE = """\ +GNU Radio Companion %s + +This program is part of GNU Radio +GRC comes with ABSOLUTELY NO WARRANTY. +This is free software, and you are welcome to redistribute it. +""" + + +def main(): + parser = optparse.OptionParser( + usage='usage: %prog [options] [saved flow graphs]', + version=VERSION_AND_DISCLAIMER_TEMPLATE % gr.version()) + options, args = parser.parse_args() + + try: + gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0)) + except: + pass + + platform = Platform( + prefs_file=gr.prefs(), + version=gr.version(), + version_parts=(gr.major_version(), gr.api_version(), gr.minor_version()), + install_prefix=gr.prefix() + ) + ActionHandler(args, platform) + gtk.main() + diff --git a/grc/scripts/gnuradio-companion b/grc/scripts/gnuradio-companion index 04529890da..04a1cb44e7 100755 --- a/grc/scripts/gnuradio-companion +++ b/grc/scripts/gnuradio-companion @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -Copyright 2009-2015 Free Software Foundation, Inc. +Copyright 2016 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -20,116 +20,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA import os import sys -import optparse -import warnings - -GR_IMPORT_ERROR_MESSAGE = """\ -Cannot import gnuradio. - -Is the model path environment variable set correctly? - All OS: PYTHONPATH - -Is the library path environment variable set correctly? - Linux: LD_LIBRARY_PATH - Windows: PATH - MacOSX: DYLD_LIBRARY_PATH -""" - -VERSION_AND_DISCLAIMER_TEMPLATE = """\ -GNU Radio Companion %s - -This program is part of GNU Radio -GRC comes with ABSOLUTELY NO WARRANTY. -This is free software, and you are welcome to redistribute it. -""" - - -def die(error, message): - msg = "{0}\n\n({1})".format(message, error) - try: - import gtk - d = gtk.MessageDialog( - type=gtk.MESSAGE_ERROR, - buttons=gtk.BUTTONS_CLOSE, - message_format=msg, - ) - d.set_title(type(error).__name__) - d.run() - exit(1) - except ImportError: - exit(type(error).__name__ + '\n\n' + msg) - - -def check_gtk(): - try: - warnings.filterwarnings("error") - import pygtk - pygtk.require('2.0') - import gtk - gtk.init_check() - warnings.filterwarnings("always") - except Exception as err: - die(err, "Failed to initialize GTK. If you are running over ssh, " - "did you enable X forwarding and start ssh with -X?") - - -def check_gnuradio_import(): - try: - from gnuradio import gr - except ImportError as err: - die(err, GR_IMPORT_ERROR_MESSAGE) - - -def check_blocks_path(): - if 'GR_DONT_LOAD_PREFS' in os.environ and not os.environ.get('GRC_BLOCKS_PATH', ''): - die(EnvironmentError("No block definitions available"), - "Can't find block definitions. Use config.conf or GRC_BLOCKS_PATH.") - - -def get_source_tree_root(): - source_tree_subpath = "/grc/scripts" - script_path = os.path.dirname(os.path.abspath(__file__)) - if script_path.endswith(source_tree_subpath): - return script_path[:-len(source_tree_subpath)] - - -def main(): - check_gnuradio_import() - - from gnuradio import gr - parser = optparse.OptionParser( - usage='usage: %prog [options] [saved flow graphs]', - version=VERSION_AND_DISCLAIMER_TEMPLATE % gr.version()) - options, args = parser.parse_args() - - check_gtk() - check_blocks_path() - source_tree_root = get_source_tree_root() - if not source_tree_root: - # run the installed version - from gnuradio.grc.gui.Platform import Platform - from gnuradio.grc.gui.ActionHandler import ActionHandler - - else: - print("Running from source tree") - sys.path.insert(1, source_tree_root) - from grc.gui.Platform import Platform - from grc.gui.ActionHandler import ActionHandler - - try: - import gtk - gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0)) - except: - pass - - ActionHandler(args, Platform( - prefs_file=gr.prefs(), - version=gr.version(), - version_parts=(gr.major_version(), gr.api_version(), gr.minor_version()), - install_prefix=gr.prefix() - )) - - -if __name__ == '__main__': - main() +script_path = os.path.dirname(os.path.abspath(__file__)) +source_tree_subpath = "/grc/scripts" + +if not script_path.endswith(source_tree_subpath): + # run the installed version + from gnuradio.grc.main import main + from gnuradio.grc import checks +else: + print("Running from source tree") + sys.path.insert(1, script_path[:-len(source_tree_subpath)]) + from grc.main import main + from grc import checks + +checks.do_all() +exit(main()) |