various: replace deprecated os.system with subprocess calls

Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
This commit is contained in:
phanirithvij
2026-07-13 06:37:05 +05:30
parent 0cd4659ead
commit 4abe0c81a7
4 changed files with 19 additions and 11 deletions

View File

@@ -347,7 +347,7 @@ def config_entry(levels: int, bootspec: BootSpec, label: str, time: str) -> str:
os.path.basename(bootspec.toplevel) + "-secrets"
)
if os.system(bootspec.initrdSecrets + " " + initrd_secrets_path_temp) != 0:
if subprocess.run([bootspec.initrdSecrets, initrd_secrets_path_temp]).returncode != 0:
print(
f'warning: failed to create initrd secrets for "{label}"',
file=sys.stderr,

View File

@@ -1,7 +1,7 @@
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3Packages.packaging python3Packages.python-debian common-updater-scripts
import os
import subprocess
from collections import OrderedDict
from os.path import abspath, dirname
from urllib import request
@@ -39,8 +39,8 @@ def write_expression():
version = Version.re_valid_version.match(latest["stable"]["Version"]).group(
"upstream_version"
)
os.system(f'update-source-version microsoft-edge "{version}"')
os.system(f'update-source-version msedgedriver "{version}"')
subprocess.run(["update-source-version", "microsoft-edge", version])
subprocess.run(["update-source-version", "msedgedriver", version])
write_expression()

View File

@@ -39,7 +39,7 @@ buildPythonPackage (finalAttrs: {
substituteInPlace tests/unit_tests.py \
--replace-fail \
'assert os.system("courlan --help") == 0' \
'assert os.system("${courlanBinPath} --help") == 0' \
'assert subprocess.run(["${courlanBinPath}", "--help"]).returncode == 0' \
--replace-fail \
'courlan_bin = "courlan"' \
'courlan_bin = "${courlanBinPath}"'

View File

@@ -1,25 +1,33 @@
diff --git a/riscof/cli.py b/riscof/cli.py
index 26af62e..9d0ddbf 100644
index 26af62e..94051ae 100644
--- a/riscof/cli.py
+++ b/riscof/cli.py
@@ -502,6 +502,7 @@ def setup(dutname,refname,work_dir):
@@ -7,6 +7,7 @@ import os
import sys
import pytz
import shutil
+import subprocess
import configparser
import distutils.dir_util
@@ -502,6 +503,7 @@ def setup(dutname,refname,work_dir):
src = os.path.join(constants.root, "Templates/setup/model/")
dest = os.path.join(cwd, dutname)
distutils.dir_util.copy_tree(src, dest)
+ os.system(f"chmod +w -R '{dest}'")
+ subprcess.run(["chmod", "+w", "-R", dest])
os.rename(cwd+'/'+dutname+'/model_isa.yaml',
cwd+'/'+dutname+'/'+dutname+'_isa.yaml')
@@ -525,10 +526,12 @@ def setup(dutname,refname,work_dir):
@@ -525,10 +527,12 @@ def setup(dutname,refname,work_dir):
src = os.path.join(constants.root, "Templates/setup/sail_cSim/")
dest = os.path.join(cwd, refname)
distutils.dir_util.copy_tree(src, dest)
+ os.system(f"chmod +w -R '{dest}'")
+ subprcess.run(["chmod", "+w", "-R", dest])
else:
src = os.path.join(constants.root, "Templates/setup/reference/")
dest = os.path.join(cwd, refname)
distutils.dir_util.copy_tree(src, dest)
+ os.system(f"chmod +w -R '{dest}'")
+ subprcess.run(["chmod", "+w", "-R", dest])
os.rename(cwd+'/'+refname+'/riscof_model.py',
cwd+'/'+refname+'/riscof_'+refname+'.py')
with open(cwd+'/'+refname+'/riscof_'+refname+'.py', 'r') as file :