From cc7558fe2c5b69e5f179f621748c4e70df8bd4dd Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Wed, 14 Oct 2020 15:52:02 +0200 Subject: [PATCH] ath10k-bdencoder: Switch to python3 Python 2.x is EOL since January 2020. The first distributions already started to drop the interpreters from their next distribution release. Just add some minor changes to make it python3 compatible. Signed-off-by: Sven Eckelmann --- tools/scripts/ath10k/ath10k-bdencoder | 35 ++++++++++++++------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/tools/scripts/ath10k/ath10k-bdencoder b/tools/scripts/ath10k/ath10k-bdencoder index 5f41a6b..1635e87 100755 --- a/tools/scripts/ath10k/ath10k-bdencoder +++ b/tools/scripts/ath10k/ath10k-bdencoder @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # Copyright (c) 2015 Qualcomm Atheros, Inc. # Copyright (c) 2018, The Linux Foundation. All rights reserved. @@ -33,7 +33,7 @@ import mailbox MAX_BUF_LEN = 2000000 # the signature length also includes null byte and padding -ATH10K_BOARD_SIGNATURE = "QCA-ATH10K-BOARD" +ATH10K_BOARD_SIGNATURE = b"QCA-ATH10K-BOARD" ATH10K_BOARD_SIGNATURE_LEN = 20 PADDING_MAGIC = 0x6d @@ -83,7 +83,7 @@ def add_ie(buf, offset, id, value): def xclip(msg): p = subprocess.Popen(['xclip', '-selection', 'clipboard'], stdin=subprocess.PIPE) - p.communicate(msg) + p.communicate(msg.encode()) # to workaround annoying python feature of returning negative hex values @@ -105,7 +105,8 @@ class BoardName(): def parse_ie(buf, offset, length): self = BoardName() fmt = '<%ds' % length - (self.name, ) = struct.unpack_from(fmt, buf, offset) + (name, ) = struct.unpack_from(fmt, buf, offset) + self.name = name.decode() logging.debug('BoardName.parse_ie(): offset %d length %d self %s' % (offset, length, self)) @@ -310,7 +311,7 @@ class BoardContainer: allnames.append(name) def _add_signature(self, buf, offset): - signature = ATH10K_BOARD_SIGNATURE + '\0' + signature = ATH10K_BOARD_SIGNATURE + b'\0' length = len(signature) pad_len = padding_needed(length) length = length + pad_len @@ -321,7 +322,7 @@ class BoardContainer: struct.pack_into('