diff options
author | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-05 18:21:05 +0100 |
---|---|---|
committer | Thomas Mangin <thomas.mangin@exa.net.uk> | 2020-04-06 20:22:35 +0100 |
commit | 0dfe1c13f257f1d3428f53e7e7078b7e3f5088b6 (patch) | |
tree | 66455f921f2da74e3fe057d0f5263ddc56d1938d /src/op_mode/show_wireless.py | |
parent | e9b0b0704e49b4ec048ba3caae9a4f0d949ebc55 (diff) | |
download | vyos-1x-0dfe1c13f257f1d3428f53e7e7078b7e3f5088b6.tar.gz vyos-1x-0dfe1c13f257f1d3428f53e7e7078b7e3f5088b6.zip |
util: T2226: rewrite show wireless to use popen
Diffstat (limited to 'src/op_mode/show_wireless.py')
-rwxr-xr-x | src/op_mode/show_wireless.py | 12 |
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': '', |