summaryrefslogtreecommitdiff
path: root/src/op_mode/show_wireless.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-07 08:27:36 +0200
committerGitHub <noreply@github.com>2020-04-07 08:27:36 +0200
commit09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c (patch)
tree6e7b0971ecd8859cff864b3ebb37f86f8ba288f5 /src/op_mode/show_wireless.py
parente0f13b79a669e7fc8cadac8757b2f5fbbf51dc99 (diff)
parent7256810914e6664bf92041dcd7c3daf649ce0001 (diff)
downloadvyos-1x-09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c.tar.gz
vyos-1x-09ad28b28c9ebd9308cfe9048686b3b0ef9cfd9c.zip
Merge pull request #307 from thomas-mangin/T2226
util: T2226: convert all call to use vyos.util.{popen, cmd, run}
Diffstat (limited to 'src/op_mode/show_wireless.py')
-rwxr-xr-xsrc/op_mode/show_wireless.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/op_mode/show_wireless.py b/src/op_mode/show_wireless.py
index aff882559..b5ee3aee1 100755
--- a/src/op_mode/show_wireless.py
+++ b/src/op_mode/show_wireless.py
@@ -19,19 +19,15 @@ import re
from sys import exit
from copy import deepcopy
-from subprocess import Popen, PIPE, STDOUT
from vyos.config import Config
+from vyos.util import popen
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--scan", help="Scan for Wireless APs on given interface, e.g. 'wlan0'")
parser.add_argument("-b", "--brief", action="store_true", help="Show wireless configuration")
parser.add_argument("-c", "--stations", help="Show wireless clients connected on interface, e.g. 'wlan0'")
-def _cmd(command):
- p = Popen(command, stdout=PIPE, stderr=STDOUT, shell=True)
- tmp = p.communicate()[0].strip()
- return tmp.decode()
def show_brief():
config = Config()
@@ -57,7 +53,8 @@ def show_brief():
return interfaces
def ssid_scan(intf):
- tmp = _cmd('/sbin/iw dev {} scan ap-force'.format(intf))
+ # XXX: This ignores errors
+ tmp, _ = popen(f'/sbin/iw dev {intf} scan ap-force')
networks = []
data = {
'ssid': '',
@@ -89,7 +86,8 @@ def ssid_scan(intf):
return networks
def show_clients(intf):
- tmp = _cmd('/sbin/iw dev {} station dump'.format(intf))
+ # XXX: This ignores errors
+ tmp, _ = popen(f'/sbin/iw dev {intf} station dump')
clients = []
data = {
'mac': '',