41,49c41
< # format. It assumes that protoc has been executed and already
< # generated the Python package for the packet messages. This can
< # be done manually using:
< # protoc --python_out=. --proto_path=src/proto src/proto/packet.proto
< #
< # The ASCII trace format uses one line per request on the format cmd,
< # addr, size, tick,flags. For example:
< # r,128,64,4000,0
< # w,232123,64,500000,0
---
> # format.
50a43
> import os
51a45
> import subprocess
54,68c48,51
< # Import the packet proto definitions. If they are not found, attempt
< # to generate them automatically.
< try:
< import packet_pb2
< except:
< print "Did not find packet proto definitions, attempting to generate"
< import os
< util_dir = os.path.dirname(os.path.realpath(__file__))
< proto_dir = os.path.join(os.path.dirname(util_dir), 'src', 'proto')
< proto_file = os.path.join(proto_dir, 'packet.proto')
< from subprocess import call
< error = call(['protoc', '--python_out=' + util_dir,
< '--proto_path=' + proto_dir, proto_file])
< if not error:
< print "Generated packet proto definitions"
---
> util_dir = os.path.dirname(os.path.realpath(__file__))
> # Make sure the proto definitions are up to date.
> subprocess.check_call(['make', '--quiet', '-C', util_dir, 'packet_pb2.py'])
> import packet_pb2
70,80d52
< try:
< import google.protobuf
< except:
< print "Please install Python protobuf module"
< exit(-1)
<
< import packet_pb2
< else:
< print "Failed to import packet proto definitions"
< exit(-1)
<