commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 03/03: utils: add error message output to g


From: git
Subject: [Commit-gnuradio] [gnuradio] 03/03: utils: add error message output to grcc
Date: Thu, 6 Nov 2014 19:39:15 +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 f60cd24f29aff06bd4895b99808ee1616294d020
Author: Sebastian Koslowski <address@hidden>
Date:   Thu Nov 6 18:06:00 2014 +0100

    utils: add error message output to grcc
---
 gr-utils/python/utils/grcc | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/gr-utils/python/utils/grcc b/gr-utils/python/utils/grcc
index 8fb44c2..82db543 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()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]