Merge pull request #897 from S1DDHEY/fix/replace-deprecated-os.popen

fix: Replaced `os.popen()` with Python's inbuilt file handling
This commit is contained in:
Nick Klockenga
2026-07-14 23:12:05 -04:00
committed by GitHub
+6 -4
View File
@@ -1,6 +1,5 @@
import hashlib
import logging
import os
import time
from gettext import gettext as _
@@ -148,9 +147,12 @@ class ToolsImageEntropyMnemonicLengthView(View):
# Build in some hardware-level uniqueness via CPU unique Serial num
try:
stream = os.popen("cat /proc/cpuinfo | grep Serial")
output = stream.read()
serial_num = output.split(":")[-1].strip().encode('utf-8')
serial_num = b''
with open("/proc/cpuinfo", "r") as f:
for line in f:
if "Serial" in line:
serial_num = line.split(":")[-1].strip().encode('utf-8')
break
serial_hash = hashlib.sha256(serial_num)
hash_bytes = serial_hash.digest()
except Exception as e: