From 58350fdb86fbdeb51ca0fa05a6ec076d7a838134 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com> Date: Fri, 23 Sep 2016 05:56:18 -0400 Subject: [PATCH] Fixed several bugs preventing python2 from running due to string encodings. --- src/apex/aprs/aprs_kiss.py | 4 ++-- src/apex/aprs/util.py | 2 +- src/apex/cli.py | 4 +--- src/apex/kiss/kiss.py | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/apex/aprs/aprs_kiss.py b/src/apex/aprs/aprs_kiss.py index 063fc3f..27005d1 100644 --- a/src/apex/aprs/aprs_kiss.py +++ b/src/apex/aprs/aprs_kiss.py @@ -48,10 +48,10 @@ class AprsKiss(apex.kiss.Kiss): # Less than 2 callsigns? if 1 < i < 11: if (raw_frame[raw_slice + 1] & 0x03 == 0x03 and raw_frame[raw_slice + 2] in [0xf0, 0xcf]): - frame['text'] = raw_frame[raw_slice + 3:] + frame['text'] = "".join(map(chr, raw_frame[raw_slice + 3:])) frame['destination'] = AprsKiss.__identity_as_string(AprsKiss.__extract_callsign(raw_frame)) frame['source'] = AprsKiss.__identity_as_string(AprsKiss.__extract_callsign(raw_frame[7:])) - frame['path'] = AprsKiss.__extract_path(math.floor(i), raw_frame) + frame['path'] = AprsKiss.__extract_path(int(i), raw_frame) return frame logging.debug('frame=%s', frame) diff --git a/src/apex/aprs/util.py b/src/apex/aprs/util.py index 6ae3d80..34df341 100755 --- a/src/apex/aprs/util.py +++ b/src/apex/aprs/util.py @@ -183,7 +183,7 @@ def run_doctest(): # pragma: no cover def hash_frame(frame): """ - Produces an integr value that acts as a hash for the frame + Produces an integer value that acts as a hash for the frame :param frame: A frame packet :type frame: dict :return: an integer representing the hash diff --git a/src/apex/cli.py b/src/apex/cli.py index 403490c..31605dc 100644 --- a/src/apex/cli.py +++ b/src/apex/cli.py @@ -15,7 +15,7 @@ Why does this file exist, and why not put this in __main__? Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration """ -# These imports are for python3 compatability inside python2 +# These imports are for python3 compatibility inside python2 from __future__ import absolute_import from __future__ import division from __future__ import print_function @@ -179,10 +179,8 @@ def main(verbose, configfile): something_read = False try: for port_name in port_map.keys(): - click.echo('reading port: %s' % port_name) port = port_map[port_name] frame = port['tnc'].read() - click.echo('raw frame read in: %s' % frame) if frame: formatted_aprs = apex.aprs.util.format_aprs_frame(frame) print(port_name + " << " + formatted_aprs) diff --git a/src/apex/kiss/kiss.py b/src/apex/kiss/kiss.py index e7a75f4..007d0b8 100644 --- a/src/apex/kiss/kiss.py +++ b/src/apex/kiss/kiss.py @@ -87,7 +87,7 @@ class Kiss(object): waiting_data = self.interface.inWaiting() if waiting_data: read_data += self.interface.read(waiting_data) - return read_data + return map(ord, read_data) @staticmethod def __strip_df_start(frame): -- GitLab