aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-05-19 21:25:10 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-05-19 21:25:10 +0300
commitf9501ca18589ff7d1983a9d79400776062ae4b71 (patch)
tree66c45bee0584316c4b3ffabe117aa289543e77d7
parentd1ca88d20ec1b205752546a40ef520a392d0002f (diff)
Add better error messages in the generator when libraries cannot be imported.
Fixes issue #5.
-rw-r--r--generator/nanopb_generator.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 2cc92f01..39153839 100644
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -1,7 +1,27 @@
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
-import google.protobuf.descriptor_pb2 as descriptor
-import nanopb_pb2
+try:
+ import google.protobuf.descriptor_pb2 as descriptor
+except:
+ print
+ print "*************************************************************"
+ print "*** Could not import the Google protobuf Python libraries ***"
+ print "*** Try installing package 'python-protobuf' or similar. ***"
+ print "*************************************************************"
+ print
+ raise
+
+try:
+ import nanopb_pb2
+except:
+ print
+ print "***************************************************************"
+ print "*** Could not import the precompiled nanopb_pb2.py. ***"
+ print "*** Run 'make' in the 'generator' folder to update the file.***"
+ print "***************************************************************"
+ print
+ raise
+
import os.path
# Values are tuple (c type, pb ltype)