summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2014-11-06 18:06:00 +0100
committerSebastian Koslowski <koslowski@kit.edu>2014-11-06 18:07:31 +0100
commitf60cd24f29aff06bd4895b99808ee1616294d020 (patch)
tree26daab4eaf5f4f19014f45c2f15aef6e79224019
parent69cec6f1b575d5afeca40923e4ea144e7e17fead (diff)
utils: add error message output to grcc
-rwxr-xr-xgr-utils/python/utils/grcc29
1 files changed, 19 insertions, 10 deletions
diff --git a/gr-utils/python/utils/grcc b/gr-utils/python/utils/grcc
index 8fb44c2c79..82db5435db 100755
--- a/gr-utils/python/utils/grcc
+++ b/gr-utils/python/utils/grcc
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+import os
+import sys
+from optparse import OptionParser
import warnings
warnings.simplefilter('ignore')
@@ -28,10 +31,8 @@ try:
except ImportError:
from gnuradio.grc.python.Platform import Platform
-from optparse import OptionParser
-import os, sys
-class grcc:
+class GRCC:
def __init__(self, grcfile, out_dir):
self.out_dir = out_dir
self.platform = Platform()
@@ -43,7 +44,9 @@ class grcc:
self.fg.validate()
if not self.fg.is_valid():
- raise StandardError("Compilation error")
+ raise StandardError("\n\n".join(
+ ["Validation failed:"] + self.fg.get_error_messages()
+ ))
self.gen = self.platform.get_generator()(self.fg, out_dir)
self.gen.write()
@@ -52,7 +55,8 @@ class grcc:
progname = self.fg.get_option('id')
os.system("{0}/{1}.py".format(self.out_dir, progname))
-if __name__ == "__main__":
+
+def main():
usage="%prog: [options] filename"
description = "Compiles a GRC file (.grc) into a GNU Radio Python program. The program is stored in ~/.grc_gnuradio by default, but this location can be changed with the -d option."
@@ -63,15 +67,20 @@ if __name__ == "__main__":
help="Run the program after compiling [default=%default]")
(options, args) = parser.parse_args ()
- if(len(args) != 1):
+ if len(args) != 1:
sys.stderr.write("Please specify a GRC file name to compile.\n")
sys.exit(1)
try:
- g = grcc(args[0], options.directory+"/")
- except:
- sys.stderr.write("Error during file compilation.\n");
+ g = GRCC(args[0], options.directory + "/")
+ except Exception as e:
+ sys.stderr.write(str(e) + "\n")
+ sys.stderr.write("Error during file compilation.\n")
sys.exit(1)
- if(options.execute):
+ if options.execute:
g.exec_program()
+
+
+if __name__ == "__main__":
+ main()