summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2019-11-17 16:42:39 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2019-11-17 17:46:48 +0700
commit2605d96720cb502ae3056027f8da383afd3f4c5c (patch)
treec8a2d5232aedbdfa211a94cf80ee8cc0a190909f
parenteb0560e19e978d5e629b286e599fa4c63a5dc753 (diff)
trx_toolkit: fix: do not use 'is' / 'is not' with string and numerical literals
Since version 3.8, Python warnins us that using the "is" and "is not" operators with string and numerical literals is a bad idea. Let's avoid this and use the classical '==' and '!=' operators instead. Change-Id: Iaed86d630ac1e0b9b4f72bbf3c788e325783456d Bug description: https://bugs.python.org/issue34850
-rwxr-xr-xsrc/target/trx_toolkit/fake_trx.py16
-rwxr-xr-xsrc/target/trx_toolkit/trx_sniff.py2
2 files changed, 9 insertions, 9 deletions
diff --git a/src/target/trx_toolkit/fake_trx.py b/src/target/trx_toolkit/fake_trx.py
index 8beee6e9..f226f032 100755
--- a/src/target/trx_toolkit/fake_trx.py
+++ b/src/target/trx_toolkit/fake_trx.py
@@ -4,7 +4,7 @@
# TRX Toolkit
# Virtual Um-interface (fake transceiver)
#
-# (C) 2017-2018 by Vadim Yanitskiy <axilirator@gmail.com>
+# (C) 2017-2019 by Vadim Yanitskiy <axilirator@gmail.com>
#
# All Rights Reserved
#
@@ -22,7 +22,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-APP_CR_HOLDERS = [("2017-2018", "Vadim Yanitskiy <axilirator@gmail.com>")]
+APP_CR_HOLDERS = [("2017-2019", "Vadim Yanitskiy <axilirator@gmail.com>")]
import logging as log
import signal
@@ -131,7 +131,7 @@ class FakeTRX(Transceiver):
@property
def toa256(self):
# Check if randomization is required
- if self.toa256_rand_threshold is 0:
+ if self.toa256_rand_threshold == 0:
return self.toa256_base
# Generate a random ToA value in required range
@@ -142,7 +142,7 @@ class FakeTRX(Transceiver):
@property
def rssi(self):
# Check if randomization is required
- if self.rssi_rand_threshold is 0:
+ if self.rssi_rand_threshold == 0:
return self.rssi_base
# Generate a random RSSI value in required range
@@ -153,7 +153,7 @@ class FakeTRX(Transceiver):
@property
def ci(self):
# Check if randomization is required
- if self.ci_rand_threshold is 0:
+ if self.ci_rand_threshold == 0:
return self.ci_base
# Generate a random C/I value in required range
@@ -165,7 +165,7 @@ class FakeTRX(Transceiver):
# Returns: True - drop, False - keep
def sim_burst_drop(self, msg):
# Check if dropping is required
- if self.burst_drop_amount is 0:
+ if self.burst_drop_amount == 0:
return False
if msg.fn % self.burst_drop_period == 0:
@@ -212,7 +212,7 @@ class FakeTRX(Transceiver):
self._handle_data_msg_v1(src_msg, msg)
# Apply optional Timing Advance
- if src_trx.ta is not 0:
+ if src_trx.ta != 0:
msg.toa256 -= src_trx.ta * 256
# Path loss simulation
@@ -384,7 +384,7 @@ class Application(ApplicationBase):
def append_child_trx(self, remote_addr, base_port, child_idx, name = None):
# Index 0 corresponds to the first transceiver
- if child_idx is 0:
+ if child_idx == 0:
self.append_trx(remote_addr, base_port, name)
return
diff --git a/src/target/trx_toolkit/trx_sniff.py b/src/target/trx_toolkit/trx_sniff.py
index 7e5c2bd6..6671c351 100755
--- a/src/target/trx_toolkit/trx_sniff.py
+++ b/src/target/trx_toolkit/trx_sniff.py
@@ -112,7 +112,7 @@ class Application(ApplicationBase):
msg.validate()
except ValueError as e:
desc = msg.desc_hdr()
- if desc is "":
+ if desc == "":
desc = "parsing error"
log.warning("Ignoring an incorrect message (%s): %s" % (desc, e))
self.cnt_burst_dropped_num += 1