summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-12-03 18:44:25 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-12-29 20:26:58 +0200
commitdde71cb426addb6e847c2443ee1bd551d9eb0637 (patch)
tree8f35f5d8e46c79c1b4fb2c0110e504e906034abd
parent1fc90ab4c4731ab521ee7f6b4f1f936f76520e2e (diff)
Make generator print errors to stderr.
Otherwise they won't be visible when run as a protoc plugin.
-rwxr-xr-xgenerator/nanopb_generator.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index 7b3c9f80..ab6f3cb5 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -3,28 +3,30 @@
'''Generate header file for nanopb from a ProtoBuf FileDescriptorSet.'''
nanopb_version = "nanopb-0.2.5-dev"
+import sys
+
try:
import google, distutils.util # bbfreeze seems to need these
import google.protobuf.text_format as text_format
except:
- print
- print "*************************************************************"
- print "*** Could not import the Google protobuf Python libraries ***"
- print "*** Try installing package 'python-protobuf' or similar. ***"
- print "*************************************************************"
- print
+ sys.stderr.write('''
+ *************************************************************
+ *** Could not import the Google protobuf Python libraries ***
+ *** Try installing package 'python-protobuf' or similar. ***
+ *************************************************************
+ ''' + '\n')
raise
try:
import proto.nanopb_pb2 as nanopb_pb2
import proto.descriptor_pb2 as descriptor
except:
- print
- print "********************************************************************"
- print "*** Failed to import the protocol definitions for generator. ***"
- print "*** You have to run 'make' in the nanopb/generator/proto folder. ***"
- print "********************************************************************"
- print
+ sys.stderr.write('''
+ ********************************************************************
+ *** Failed to import the protocol definitions for generator. ***
+ *** You have to run 'make' in the nanopb/generator/proto folder. ***
+ ********************************************************************
+ ''' + '\n')
raise