replace all check_call with subprocess.run
This commit is contained in:
14
start_wg.py
14
start_wg.py
@ -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
|
||||
|
Reference in New Issue
Block a user