summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-02-28 15:08:58 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-02-28 15:08:58 +0700
commitd93c1debb0f2b782c7b051c338753508bd6bca23 (patch)
treeb5bd9c1035753bd4841c4f44589b8704b6a94ae9
parent77492b792619d66f5395cb0f000d053afb73f9c4 (diff)
fake_trx/data_dump.py: fix python3 compatibility
There is no 'file' type in Python3 anymore, so let's reverse the condition in DATADumpFile constructor. Also, the tag definition was incorrect: both '\x01' and b'\x01' aren't the same. Change-Id: Ib00c7f0bd5871fcfce931a4bfa501ae5bf797c45
-rw-r--r--src/target/fake_trx/data_dump.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/target/fake_trx/data_dump.py b/src/target/fake_trx/data_dump.py
index 56e314c4..6102dc56 100644
--- a/src/target/fake_trx/data_dump.py
+++ b/src/target/fake_trx/data_dump.py
@@ -28,8 +28,8 @@ from data_msg import *
class DATADump:
# Constants
- TAG_L12TRX = '\x01'
- TAG_TRX2L1 = '\x02'
+ TAG_L12TRX = b'\x01'
+ TAG_TRX2L1 = b'\x02'
HDR_LENGTH = 3
# Generates raw bytes from a DATA message
@@ -58,7 +58,7 @@ class DATADump:
def parse_hdr(self, hdr):
# Extract the header info
msg_len = struct.unpack(">H", hdr[1:3])[0]
- tag = hdr[0]
+ tag = hdr[:1]
# Check if tag is known
if tag == self.TAG_L12TRX:
@@ -76,11 +76,11 @@ class DATADump:
class DATADumpFile(DATADump):
def __init__(self, capture):
# Check if capture file is already opened
- if type(capture) is file:
- self.f = capture
- else:
+ if isinstance(capture, str):
print("[i] Opening capture file '%s'..." % capture)
self.f = open(capture, "a+b")
+ else:
+ self.f = capture
def __del__(self):
print("[i] Closing the capture file")