[Concept,09/13] scripts: ubuntu: Use command.run() in hash_password()
Commit Message
From: Simon Glass <sjg@chromium.org>
The rest of the script funnels every external invocation through
u_boot_pylib's command.run(), so its CommandExc carries the captured
output on failure and the -v/-quiet wiring keeps subprocess chatter out
of the default run. hash_password() is the lone holdout, going straight
to subprocess.run() to feed the plaintext password through stdin.
command.run() takes the same data via stdin_data= and returns the
captured stdout as a string when capture=True, so the conversion keeps
the no-arg-on-the-command-line property of the password input and lets
us drop the subprocess import altogether.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
scripts/ubuntu-iso-to-uboot.py | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
@@ -66,7 +66,6 @@ import argparse
import os
import re
import shutil
-import subprocess
import sys
import tempfile
from pathlib import Path
@@ -339,11 +338,10 @@ def hash_password(password: str) -> str:
password. Shelling out to openssl keeps the script's dependency list
unchanged (Python's crypt module is gone in 3.13).
"""
- out = subprocess.run(
- ['openssl', 'passwd', '-6', '-stdin'],
- input=password, capture_output=True, text=True, check=True,
- )
- return out.stdout.strip()
+ return command.run(
+ 'openssl', 'passwd', '-6', '-stdin',
+ capture=True, stdin_data=password,
+ ).strip()
def autoinstall_yaml(