summaryrefslogtreecommitdiff
path: root/util/decode_packet_trace.py
diff options
context:
space:
mode:
authorRadhika Jagtap <radhika.jagtap@ARM.com>2014-08-10 05:39:20 -0400
committerRadhika Jagtap <radhika.jagtap@ARM.com>2014-08-10 05:39:20 -0400
commit2ee47fc8d1e3c6089e3e358603dadca913a4527c (patch)
tree06e9fa372ad2e75a38acaca6d6757404f9c2ef56 /util/decode_packet_trace.py
parentdbdce42b88f9b1f954b1bbb5ae9c707a6a3c1d0c (diff)
downloadgem5-2ee47fc8d1e3c6089e3e358603dadca913a4527c.tar.xz
util: Move packet trace file read to protolib
This patch moves the code for opening an input protobuf packet trace into a function defined in the protobuf library. This is because the code is commonly used in decode scripts and is independent of the src protobuf message.
Diffstat (limited to 'util/decode_packet_trace.py')
-rwxr-xr-xutil/decode_packet_trace.py19
1 files changed, 2 insertions, 17 deletions
diff --git a/util/decode_packet_trace.py b/util/decode_packet_trace.py
index e6f36c295..e9105753d 100755
--- a/util/decode_packet_trace.py
+++ b/util/decode_packet_trace.py
@@ -48,7 +48,6 @@
# r,128,64,4000,0
# w,232123,64,500000,0
-import gzip
import protolib
import sys
@@ -81,22 +80,8 @@ def main():
print "Usage: ", sys.argv[0], " <protobuf input> <ASCII output>"
exit(-1)
- try:
- # First see if this file is gzipped
- try:
- # Opening the file works even if it is not a gzip file
- proto_in = gzip.open(sys.argv[1], 'rb')
-
- # Force a check of the magic number by seeking in the
- # file. If we do not do it here the error will occur when
- # reading the first message.
- proto_in.seek(1)
- proto_in.seek(0)
- except IOError:
- proto_in = open(sys.argv[1], 'rb')
- except IOError:
- print "Failed to open ", sys.argv[1], " for reading"
- exit(-1)
+ # Open the file in read mode
+ proto_in = protolib.openFileRd(sys.argv[1])
try:
ascii_out = open(sys.argv[2], 'w')