Skip to content

Commit ffa6339

Browse files
committed
net: Fix python code using ruff
This auto-fixes the code using ruff Signed-off-by: Jamie McCrae <[email protected]>
1 parent 6cdeddd commit ffa6339

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

lib/bin/lwm2m_carrier/scripts/lwm2m_carrier_divided_dfu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
66

77
import argparse
8+
import errno
89
import os
910
import struct
10-
import errno
1111

1212
HEADER_LENGTH = 42
1313
HEADER_MAGIC = 0x424ad2dc
@@ -94,7 +94,7 @@ def main():
9494
chunk = header.encode() + chunk
9595

9696
# Generate file name of each chunk.
97-
chunk_version_str = version_str + '_{0:03d}.bin'.format(i + 1)
97+
chunk_version_str = version_str + f'_{i + 1:03d}.bin'
9898

9999
# Write the chunk into the output directory.
100100
with open(os.path.join(output_dir, chunk_version_str), 'wb') as chunk_file:

subsys/net/lib/wifi_prov_core/proto/generate_wifi_prov_config.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
1414
"""
1515

16-
import os
17-
import sys
1816
import argparse
1917
import base64
18+
import os
19+
import sys
2020

2121
# Import generated protobuf modules
2222
try:
23-
from request_pb2 import Request, WifiConfig, EnterpriseCertConfig
24-
from common_pb2 import WifiInfo, AuthMode, Band, OpCode
23+
from common_pb2 import AuthMode, Band, OpCode, WifiInfo
24+
from request_pb2 import EnterpriseCertConfig, Request, WifiConfig
2525
except ImportError:
2626
print("Error: Python protobuf defigdnitions not found.")
2727
print("Please ensure the CMake build has generated the protobuf files.")
@@ -47,8 +47,8 @@ def read_cert_file(file_path):
4747
try:
4848
with open(file_path, 'rb') as f:
4949
return f.read()
50-
except IOError as e:
51-
raise IOError(f"Failed to read certificate file {file_path}: {e}")
50+
except OSError as e:
51+
raise OSError(f"Failed to read certificate file {file_path}: {e}")
5252

5353
def check_required_files(cert_dir):
5454
"""Check if all required certificate files exist.
@@ -289,6 +289,7 @@ def main():
289289
# Show JSON only if requested
290290
if args.json:
291291
import json
292+
292293
from google.protobuf.json_format import MessageToDict
293294

294295
json_data = MessageToDict(request, preserving_proto_field_name=True)
@@ -306,6 +307,7 @@ def main():
306307
if args.json:
307308
# Save as JSON
308309
import json
310+
309311
from google.protobuf.json_format import MessageToDict
310312
json_data = MessageToDict(request, preserving_proto_field_name=True)
311313
with open(args.output, 'w') as f:
@@ -350,17 +352,17 @@ def main():
350352
}
351353
auth_name = auth_names.get(args.auth_mode, f"Unknown({args.auth_mode})")
352354

353-
print(f"\nConfiguration details:")
355+
print("\nConfiguration details:")
354356
print(f" SSID: {args.ssid}")
355357
print(f" BSSID: {args.bssid}")
356358
print(f" Channel: {args.channel}")
357359
print(f" Band: {'2.4GHz' if args.band == 1 else '5GHz'}")
358360
print(f" Auth: {auth_name}")
359361
if args.cert_dir:
360-
print(f" Mode: EAP-TLS")
362+
print(" Mode: EAP-TLS")
361363
print(f" Identity: {args.identity}")
362364
elif args.passphrase:
363-
print(f" Mode: Personal")
365+
print(" Mode: Personal")
364366
print(f" Passphrase: {'*' * len(args.passphrase)}")
365367

366368
if __name__ == "__main__":

subsys/net/lib/wifi_prov_core/proto/test_auth_modes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
88
"""
99

10-
import sys
1110
import os
11+
import sys
1212

1313
# Add current directory to path to import the script
1414
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

0 commit comments

Comments
 (0)