Skip to content

Commit 87634e0

Browse files
ci(pre-commit): Apply automatic fixes
1 parent c483fa7 commit 87634e0

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

libraries/WiFi/examples/WiFiUDPClient/udp_server.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import subprocess
66
import platform
77

8+
89
def get_interface_ips():
910
"""Get all available interface IP addresses"""
1011
interface_ips = []
@@ -15,31 +16,31 @@ def get_interface_ips():
1516
try:
1617
if system == "darwin" or system == "linux":
1718
# Use 'ifconfig' on macOS/Linux
18-
result = subprocess.run(['ifconfig'], capture_output=True, text=True, timeout=5)
19+
result = subprocess.run(["ifconfig"], capture_output=True, text=True, timeout=5)
1920
if result.returncode == 0:
20-
lines = result.stdout.split('\n')
21+
lines = result.stdout.split("\n")
2122
for line in lines:
22-
if 'inet ' in line and '127.0.0.1' not in line:
23+
if "inet " in line and "127.0.0.1" not in line:
2324
# Extract IP address from ifconfig output
2425
parts = line.strip().split()
2526
for i, part in enumerate(parts):
26-
if part == 'inet':
27+
if part == "inet":
2728
if i + 1 < len(parts):
2829
ip = parts[i + 1]
29-
if ip not in interface_ips and ip != '127.0.0.1':
30+
if ip not in interface_ips and ip != "127.0.0.1":
3031
interface_ips.append(ip)
3132
break
3233
elif system == "windows":
3334
# Use 'ipconfig' on Windows
34-
result = subprocess.run(['ipconfig'], capture_output=True, text=True, timeout=5)
35+
result = subprocess.run(["ipconfig"], capture_output=True, text=True, timeout=5)
3536
if result.returncode == 0:
36-
lines = result.stdout.split('\n')
37+
lines = result.stdout.split("\n")
3738
for line in lines:
38-
if 'IPv4 Address' in line and '127.0.0.1' not in line:
39+
if "IPv4 Address" in line and "127.0.0.1" not in line:
3940
# Extract IP address from ipconfig output
40-
if ':' in line:
41-
ip = line.split(':')[1].strip()
42-
if ip not in interface_ips and ip != '127.0.0.1':
41+
if ":" in line:
42+
ip = line.split(":")[1].strip()
43+
if ip not in interface_ips and ip != "127.0.0.1":
4344
interface_ips.append(ip)
4445
except (subprocess.TimeoutExpired, subprocess.SubprocessError, FileNotFoundError):
4546
print("Error: Failed to get interface IPs using system commands")
@@ -52,7 +53,7 @@ def get_interface_ips():
5253
hostname = socket.gethostname()
5354
ip_list = socket.gethostbyname_ex(hostname)[2]
5455
for ip in ip_list:
55-
if ip not in interface_ips and ip != '127.0.0.1':
56+
if ip not in interface_ips and ip != "127.0.0.1":
5657
interface_ips.append(ip)
5758
except socket.gaierror:
5859
print("Error: Failed to get interface IPs using sockets")
@@ -64,6 +65,7 @@ def get_interface_ips():
6465

6566
return interface_ips
6667

68+
6769
def select_interface(interface_ips):
6870
"""Ask user to select which interface to bind to"""
6971
if len(interface_ips) == 1:
@@ -90,6 +92,7 @@ def select_interface(interface_ips):
9092
print("\nExiting...")
9193
sys.exit(1)
9294

95+
9396
try:
9497
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
9598
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

tools/espota.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
# Constants
5555
PROGRESS_BAR_LENGTH = 60
5656

57+
5758
# update_progress(): Displays or updates a console progress bar
5859
def update_progress(progress):
5960
if PROGRESS:
@@ -144,7 +145,7 @@ def serve(remote_addr, local_addr, remote_port, local_port, password, filename,
144145

145146
# 2. Derive key using PBKDF2-HMAC-SHA256 with the password hash
146147
salt = nonce + ":" + cnonce
147-
derived_key = hashlib.pbkdf2_hmac('sha256', password_hash.encode(), salt.encode(), 10000)
148+
derived_key = hashlib.pbkdf2_hmac("sha256", password_hash.encode(), salt.encode(), 10000)
148149
derived_key_hex = derived_key.hex()
149150

150151
# 3. Create challenge response

tools/get.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
def is_safe_archive_path(path):
5454
# Check for absolute paths (both Unix and Windows style)
55-
if path.startswith('/') or (len(path) > 1 and path[1] == ':' and path[2] in '\\/'):
55+
if path.startswith("/") or (len(path) > 1 and path[1] == ":" and path[2] in "\\/"):
5656
raise ValueError(f"Absolute path not allowed: {path}")
5757

5858
# Normalize the path to handle any path separators
@@ -68,8 +68,8 @@ def is_safe_archive_path(path):
6868

6969
# Check for any remaining directory traversal patterns in the original path
7070
# This catches cases that might not be normalized properly
71-
path_parts = path.replace('\\', '/').split('/')
72-
if '..' in path_parts:
71+
path_parts = path.replace("\\", "/").split("/")
72+
if ".." in path_parts:
7373
raise ValueError(f"Directory traversal not allowed: {path}")
7474

7575
return True

0 commit comments

Comments
 (0)