replace all check_call with subprocess.run
This commit is contained in:
30
wirepy.py
30
wirepy.py
@ -11,7 +11,7 @@ import sys
|
||||
import tkinter as tk
|
||||
import webbrowser
|
||||
from pathlib import Path
|
||||
from subprocess import check_call
|
||||
from subprocess import CompletedProcess
|
||||
from tkinter import TclError, filedialog, ttk
|
||||
|
||||
from common_tools import (
|
||||
@ -645,7 +645,7 @@ class FrameWidgets(ttk.Frame):
|
||||
def import_sl(self) -> None:
|
||||
"""validity check of wireguard config files"""
|
||||
|
||||
Create.dir_and_files()
|
||||
AppConfig.ensure_directories()
|
||||
try:
|
||||
filepath = filedialog.askopenfilename(
|
||||
initialdir=f"{Path.home()}",
|
||||
@ -696,10 +696,12 @@ class FrameWidgets(ttk.Frame):
|
||||
new_conf = f"{AppConfig.TEMP_DIR}/{path_split}"
|
||||
|
||||
if self.a != "":
|
||||
check_call(["nmcli", "connection", "down", self.a])
|
||||
process: CompletedProcess[str] = subprocess.run(
|
||||
["nmcli", "connection", "down", self.a]
|
||||
)
|
||||
self.reset_fields()
|
||||
|
||||
subprocess.check_output(
|
||||
process: CompletedProcess[str] = subprocess.run(
|
||||
[
|
||||
"nmcli",
|
||||
"connection",
|
||||
@ -716,10 +718,12 @@ class FrameWidgets(ttk.Frame):
|
||||
shutil.copy(filepath, f"{AppConfig.TEMP_DIR}/")
|
||||
|
||||
if self.a != "":
|
||||
check_call(["nmcli", "connection", "down", self.a])
|
||||
process: CompletedProcess[str] = subprocess.run(
|
||||
["nmcli", "connection", "down", self.a]
|
||||
)
|
||||
self.reset_fields()
|
||||
|
||||
subprocess.check_output(
|
||||
process: CompletedProcess[str] = subprocess.run(
|
||||
[
|
||||
"nmcli",
|
||||
"connection",
|
||||
@ -760,7 +764,7 @@ class FrameWidgets(ttk.Frame):
|
||||
self.color_label()
|
||||
self.stop()
|
||||
data = self.handle_tunnel_data(self.a)
|
||||
check_call(
|
||||
process: CompletedProcess[str] = subprocess.run(
|
||||
[
|
||||
"nmcli",
|
||||
"con",
|
||||
@ -801,7 +805,9 @@ class FrameWidgets(ttk.Frame):
|
||||
) as file2:
|
||||
key = Tunnel.con_to_dict(file2)
|
||||
pre_key = key[3]
|
||||
check_call(["nmcli", "connection", "delete", select_tl])
|
||||
process: CompletedProcess[str] = subprocess.run(
|
||||
["nmcli", "connection", "delete", select_tl]
|
||||
)
|
||||
self.l_box.delete(self.select_tunnel[0])
|
||||
with open(AppConfig.SETTINGS_FILE, "r", encoding="utf-8") as set_f6:
|
||||
lines6 = set_f6.readlines()
|
||||
@ -1145,7 +1151,9 @@ class FrameWidgets(ttk.Frame):
|
||||
"""
|
||||
if action == "stop":
|
||||
if self.a:
|
||||
check_call(["nmcli", "connection", "down", self.a])
|
||||
process: CompletedProcess[str] = subprocess.run(
|
||||
["nmcli", "connection", "down", self.a]
|
||||
)
|
||||
self.update_connection_display()
|
||||
self.reset_fields()
|
||||
self.start()
|
||||
@ -1153,7 +1161,9 @@ class FrameWidgets(ttk.Frame):
|
||||
elif action == "start":
|
||||
if tunnel_name or self.a:
|
||||
target_tunnel = tunnel_name or self.a
|
||||
check_call(["nmcli", "connection", "up", target_tunnel])
|
||||
process: CompletedProcess[str] = subprocess.run(
|
||||
["nmcli", "connection", "up", target_tunnel]
|
||||
)
|
||||
self.update_connection_display()
|
||||
data = self.handle_tunnel_data(self.a)
|
||||
self.init_and_report(data)
|
||||
|
Reference in New Issue
Block a user