diff --git a/src/lib/api/service_compiler/plugin.py b/src/lib/api/service_compiler/plugin.py index 2a019710e..78c78d98e 100755 --- a/src/lib/api/service_compiler/plugin.py +++ b/src/lib/api/service_compiler/plugin.py @@ -1,4 +1,5 @@ #!/usr/bin/python +from __future__ import print_function import os, sys from collections import namedtuple @@ -30,8 +31,8 @@ import apioptions_pb2 def loadTemplate(lang, name): path = os.path.join("templates", lang, name) text = open(path).read() - utext = unicode(text, "utf-8") - return compiler.compile(utext) + #utext = unicode(text, "utf-8") + return compiler.compile(text) def option(options, key, default=None): if options.HasExtension(key): @@ -307,7 +308,7 @@ if __name__ == "__main__": if DEBUG: data = open("data", mode='rb').read() else: - data = sys.stdin.read() + data = sys.stdin.buffer.read() request = plugin.CodeGeneratorRequest() # open("data", 'wb').write(data) request.ParseFromString(data) @@ -316,8 +317,8 @@ if __name__ == "__main__": if DEBUG: for f in response.file: - print f.content + print(f.content) else: output = response.SerializeToString() - sys.stdout.write(output) + sys.stdout.buffer.write(output)