a2e3bc28ace73b141279cd45150959e475e2b5b0
[debian/gnuradio] / grc / scripts / grc
1 #!/usr/bin/env python
2 """
3 Copyright 2009 Free Software Foundation, Inc.
4 This file is part of GNU Radio
5
6 GNU Radio Companion is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 GNU Radio Companion is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
19 """
20
21 import os
22
23 import pygtk
24 pygtk.require('2.0')
25 import gtk
26
27 try: from gnuradio import gr
28 except ImportError, e:
29         d = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="""
30 Cannot import gnuradio. Are your PYTHONPATH and LD_LIBRARY_PATH set correctly?""")
31         d.set_title(str(e))
32         d.run()
33         exit(-1)
34
35 from gnuradio.grc.platforms.base.Constants import VERSION
36 from optparse import OptionParser
37
38 if __name__ == "__main__":
39         usage = 'usage: %prog [options] [saved flow graphs]'
40         version = """
41 GNU Radio Companion %s
42
43 This program is part of GNU Radio
44 GRC comes with ABSOLUTELY NO WARRANTY.
45 This is free software,
46 and you are welcome to redistribute it.
47 """%VERSION
48         parser = OptionParser(usage=usage, version=version)
49         (options, args) = parser.parse_args()
50         from gnuradio.grc.platforms.python.Platform import Platform
51         from gnuradio.grc.gui.ActionHandler import ActionHandler
52         #setup icon using icon theme
53         try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0))
54         except: pass
55         #extract extra block paths from environment variable, separated by semicolon
56         try: extra_blocks = os.environ['GRC_BLOCKS_PATH'].split(';')
57         except: extra_blocks = list()
58         ActionHandler(args, Platform(extra_blocks=extra_blocks))
59