summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-07-16 00:30:54 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-10-23 22:05:49 +0330
commit00a448c5e8c83efc8d3d7794bf6b15f03d5f9f8a (patch)
tree660d7a3523e6106e02715e31adc91795ef079675
parent5ba6e8c21b2eeafc1c9a93f4430fd8c87a068b7e (diff)
fake_trx: fix compatibility with Python 3
-rwxr-xr-xsrc/target/fake_trx/clck_gen.py2
-rwxr-xr-xsrc/target/fake_trx/ctrl_cmd.py2
-rwxr-xr-xsrc/target/fake_trx/fake_trx.py4
-rw-r--r--src/target/fake_trx/udp_link.py5
4 files changed, 8 insertions, 5 deletions
diff --git a/src/target/fake_trx/clck_gen.py b/src/target/fake_trx/clck_gen.py
index 4ef597f6..f1c1f983 100755
--- a/src/target/fake_trx/clck_gen.py
+++ b/src/target/fake_trx/clck_gen.py
@@ -94,7 +94,7 @@ class Application:
self.clck.start()
def sig_handler(self, signum, frame):
- print "Signal %d received" % signum
+ print("Signal %d received" % signum)
if signum is signal.SIGINT:
self.clck.stop()
self.link.shutdown()
diff --git a/src/target/fake_trx/ctrl_cmd.py b/src/target/fake_trx/ctrl_cmd.py
index a9c7d68a..e362408f 100755
--- a/src/target/fake_trx/ctrl_cmd.py
+++ b/src/target/fake_trx/ctrl_cmd.py
@@ -54,7 +54,7 @@ class Application:
if self.ctrl_link.sock in r_event:
data, addr = self.ctrl_link.sock.recvfrom(128)
- sys.stdout.write("\r%s\n" % data)
+ sys.stdout.write("\r%s\n" % data.decode())
sys.stdout.flush()
def handle_cmd(self, cmd):
diff --git a/src/target/fake_trx/fake_trx.py b/src/target/fake_trx/fake_trx.py
index aaa308d7..b1860716 100755
--- a/src/target/fake_trx/fake_trx.py
+++ b/src/target/fake_trx/fake_trx.py
@@ -114,12 +114,12 @@ class Application:
# CTRL commands from BTS
if self.bts_ctrl.sock in r_event:
data, addr = self.bts_ctrl.sock.recvfrom(128)
- self.bts_ctrl.handle_rx(data)
+ self.bts_ctrl.handle_rx(data.decode())
# CTRL commands from BB
if self.bb_ctrl.sock in r_event:
data, addr = self.bb_ctrl.sock.recvfrom(128)
- self.bb_ctrl.handle_rx(data)
+ self.bb_ctrl.handle_rx(data.decode())
def shutdown(self):
print("[i] Shutting down...")
diff --git a/src/target/fake_trx/udp_link.py b/src/target/fake_trx/udp_link.py
index 3fa50502..0afd1504 100644
--- a/src/target/fake_trx/udp_link.py
+++ b/src/target/fake_trx/udp_link.py
@@ -41,12 +41,15 @@ class UDPLink:
# Check for incoming data
if self.sock in r_event:
data, addr = self.sock.recvfrom(128)
- self.handle_rx(data)
+ self.handle_rx(data.decode())
def shutdown(self):
self.sock.close();
def send(self, data):
+ if type(data) not in [bytearray, bytes]:
+ data = data.encode()
+
self.sock.sendto(data, (self.remote_addr, self.remote_port))
def handle_rx(self, data):