replace all check_call with subprocess.run

This commit is contained in:
2025-05-11 22:00:28 +02:00
parent 6604650adf
commit fb0158d1cd
5 changed files with 98 additions and 129 deletions

View File

@ -4,13 +4,23 @@
"""
from pathlib import Path
from subprocess import check_call
import subprocess
from subprocess import CompletedProcess
path_to_file = Path(Path.home() / ".config/wire_py/settings")
a_con = Path(path_to_file).read_text(encoding="utf-8").splitlines(keepends=True)
a_con = a_con[7].strip()
if a_con != "off":
check_call(["nmcli", "connection", "up", a_con])
process: CompletedProcess[str] = subprocess.run(
["nmcli", "connection", "up", a_con],
capture_output=True,
text=True,
check=False,
)
# Output from start_wg error
if process.stderr:
print(process.stderr) # this is for the error, later on logfile
else:
pass