From 35295618d3e29fb8e3ec3c4eb1734a79bb0b9ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Michalak-Szmaci=C5=84ski?= Date: Tue, 28 Feb 2023 16:28:49 +0100 Subject: [PATCH] [NXP] Add to flake8 in workflow and fix python files (part #25193) (#25305) * [NXP] Add to flake8 in workflow and fix python files * Restyled by isort --------- Co-authored-by: Restyled.io --- .flake8 | 4 ---- examples/platform/nxp/k32w/k32w0/scripts/detokenizer.py | 6 +++--- scripts/tools/nxp/factory_data_generator/custom.py | 2 +- scripts/tools/nxp/factory_data_generator/default.py | 1 - scripts/tools/nxp/factory_data_generator/generate.py | 5 +++-- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/.flake8 b/.flake8 index 5d254aff4e1ae2..20cfee8ad836b1 100644 --- a/.flake8 +++ b/.flake8 @@ -23,7 +23,6 @@ exclude = third_party examples/common/pigweed/rpc_console/py/chip_rpc/console.py examples/lighting-app/python/lighting.py examples/platform/mbed/ota/generate_ota_list_image.py - examples/platform/nxp/k32w/k32w0/scripts/detokenizer.py scripts/build/build/target.py scripts/build/build/targets.py scripts/build/builders/android.py @@ -81,9 +80,6 @@ exclude = third_party scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py scripts/tools/nrfconnect/nrfconnect_generate_partition.py scripts/tools/nrfconnect/tests/test_generate_factory_data.py - scripts/tools/nxp/factory_data_generator/custom.py - scripts/tools/nxp/factory_data_generator/default.py - scripts/tools/nxp/factory_data_generator/generate.py scripts/tools/silabs/FactoryDataProvider.py scripts/tools/telink/mfg_tool.py scripts/tools/zap/generate.py diff --git a/examples/platform/nxp/k32w/k32w0/scripts/detokenizer.py b/examples/platform/nxp/k32w/k32w0/scripts/detokenizer.py index 4ad1436a71fc8b..a4035d0655baa1 100644 --- a/examples/platform/nxp/k32w/k32w0/scripts/detokenizer.py +++ b/examples/platform/nxp/k32w/k32w0/scripts/detokenizer.py @@ -53,7 +53,7 @@ def decode_string(tstr, detok): if s.find('$') == 0: return None return s - except: + except ValueError: return None @@ -88,7 +88,7 @@ def decode_serial(serialport, outfile, database): print(line, file=sys.stdout) if output: print(line, file=output) - except: + except Exception: print("Serial error or program closed", file=sys.stderr) if output: @@ -120,7 +120,7 @@ def decode_file(infile, outfile, database): # ascii decode line # serial terminals may include non ascii characters line = line.decode('ascii').strip() - except: + except Exception: continue # find token start and detokenize idx = line.rfind(']') diff --git a/scripts/tools/nxp/factory_data_generator/custom.py b/scripts/tools/nxp/factory_data_generator/custom.py index e272921d81fc7a..13b1a34fc98c12 100644 --- a/scripts/tools/nxp/factory_data_generator/custom.py +++ b/scripts/tools/nxp/factory_data_generator/custom.py @@ -49,7 +49,7 @@ def custom_function(self): from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.serialization import load_der_private_key -from default import * +from default import Base64Argument, FileArgument, IntArgument, StrArgument class Verifier(Base64Argument): diff --git a/scripts/tools/nxp/factory_data_generator/default.py b/scripts/tools/nxp/factory_data_generator/default.py index c2c3b39d615bc2..13dc0866aaed40 100644 --- a/scripts/tools/nxp/factory_data_generator/default.py +++ b/scripts/tools/nxp/factory_data_generator/default.py @@ -29,7 +29,6 @@ import base64 import logging -import sys class InputArgument: diff --git a/scripts/tools/nxp/factory_data_generator/generate.py b/scripts/tools/nxp/factory_data_generator/generate.py index 24beb361a31c13..daf1b5d1267cb7 100755 --- a/scripts/tools/nxp/factory_data_generator/generate.py +++ b/scripts/tools/nxp/factory_data_generator/generate.py @@ -19,11 +19,12 @@ import argparse import hashlib import logging -import os import subprocess import sys -from custom import * +from custom import (CertDeclaration, DacCert, DacPKey, Discriminator, HardwareVersion, HardwareVersionStr, IterationCount, + ManufacturingDate, PaiCert, PartNumber, ProductId, ProductLabel, ProductName, ProductURL, Salt, SerialNum, + SetupPasscode, StrArgument, UniqueId, VendorId, VendorName, Verifier) from default import InputArgument