[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 11/25: grc: defer check for gtk init until
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 11/25: grc: defer check for gtk init until after arg parsing |
Date: |
Wed, 23 Sep 2015 14:51:38 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 8586a1faa144a32b87972e4890a54bcbec718338
Author: Sebastian Koslowski <address@hidden>
Date: Tue Aug 4 11:43:06 2015 +0200
grc: defer check for gtk init until after arg parsing
---
grc/scripts/gnuradio-companion | 64 ++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 31 deletions(-)
diff --git a/grc/scripts/gnuradio-companion b/grc/scripts/gnuradio-companion
index 77345be..203a8c7 100755
--- a/grc/scripts/gnuradio-companion
+++ b/grc/scripts/gnuradio-companion
@@ -23,15 +23,6 @@ import sys
import optparse
import warnings
-import pygtk
-pygtk.require('2.0')
-
-warnings.filterwarnings("error")
-try:
- import gtk
-except:
- sys.exit("Failed to import gtk. If you are running over ssh, did you
enable X forwarding and start ssh with -X?")
-warnings.filterwarnings("always")
GR_IMPORT_ERROR_MESSAGE = """\
Cannot import gnuradio.
@@ -54,36 +45,46 @@ This is free software, and you are welcome to redistribute
it.
"""
-def show_gtk_error_dialog(title, message):
- d = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE,
- message_format=message)
- d.set_title(title)
- d.run()
+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_init():
+def check_gtk():
try:
+ warnings.filterwarnings("error")
+ import pygtk
+ pygtk.require('2.0')
+ import gtk
gtk.init_check()
- except RuntimeError:
- print 'GTK initialization failed - bailing'
- exit(-1)
+ 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 e:
- show_gtk_error_dialog(str(e), GR_IMPORT_ERROR_MESSAGE)
- exit(-1)
+ except ImportError as err:
+ die(err, GR_IMPORT_ERROR_MESSAGE)
-def ensure_blocks_path():
+def check_blocks_path():
if 'GR_DONT_LOAD_PREFS' in os.environ and not
os.environ.get('GRC_BLOCKS_PATH', ''):
- show_gtk_error_dialog(
- title="No block definitions available.",
- message="Can't find block definitions. Use config.conf or
GRC_BLOCKS_PATH."
- )
- exit(-1)
+ die(EnvironmentError("No block definitions available"),
+ "Can't find block definitions. Use config.conf or
GRC_BLOCKS_PATH.")
def get_source_tree_root():
@@ -94,13 +95,16 @@ def get_source_tree_root():
def main():
- from gnuradio import gr
+ 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
@@ -114,6 +118,7 @@ def main():
from grc.gui.ActionHandler import ActionHandler
try:
+ import gtk
gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc',
256, 0))
except:
pass
@@ -122,7 +127,4 @@ def main():
if __name__ == '__main__':
- check_gtk_init()
- check_gnuradio_import()
- ensure_blocks_path()
main()
- [Commit-gnuradio] [gnuradio] branch master updated (aae6445 -> 45faa98), git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 08/25: polar: updated VOLK pointer to volk/volk/master with polar kernels merged, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 17/25: fec: polar: renaming GRC file names to be consistent with other codes and variable names., git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 20/25: fec: polar: Installing more FEC examples., git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 09/25: polar: fixed bugs in init code, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 12/25: Fix the VOLKized fft_vcc_fftw and QA code, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 23/25: volk: update submodule to latest, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 11/25: grc: defer check for gtk init until after arg parsing,
git <=
- [Commit-gnuradio] [gnuradio] 18/25: Merge branch 'socis/master' into polar, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 22/25: Merge remote-tracking branch 'geiger/volkize_fft_fix', git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 10/25: polar: rebased and fixed branch for merge again., git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 19/25: polar: rearranged polar_code_example flowgraph, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 21/25: Merge branch 'maint', git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 05/25: polar: VOLK kernel integration, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 24/25: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 07/25: polar: updated polar code example GRC, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 02/25: polar: encoder implemented in C++, git, 2015/09/23
- [Commit-gnuradio] [gnuradio] 25/25: Merge remote-tracking branch 'tom/socis/master', git, 2015/09/23