robotframework/lib/ap/command_wi.py

171 lines
5.4 KiB
Python

from ap.connect import *
#################################################################################################
#################################################################################################
def ap_show_wireless(alias, argv="", Downnumber='13',timeout=''):
''' *函数说明*: 查看cat /etc/config/wireless
*参数说明*:
Downnumber 过滤向下显示行数
--grep: 指定过滤条件, 类型: str, 可选iface(0,1,2,3),5gif(0,1,2,3)
*命令说明*:
cat /etc/config/wireless
cat /etc/config/wireless | grep -A 12 iface1
*example*:
ap_show_wireless ap
ap_show_wireless ap --grep iface1
*返回值*:
show出来的信息
'''
grep = ''
ret = ''
if argv:
cmd = argv.strip().split()
i = 0
while i < len(cmd):
tmpOpt = cmd[i]
if tmpOpt == '--grep':
i+=1
grep = cmd[i]
i+=1
ret = send_command_AP(alias, 'cat /etc/config/wireless',timeout)
if grep:
ret = send_command_AP(alias, 'cat /etc/config/wireless | grep -A %s %s' % (Downnumber,grep),timeout)
return ret
#################################################################################################
#################################################################################################
def ap_show_ifconfig(alias, argv="", timeout=''):
''' *函数说明*: 查看ifconfig
*参数说明*:
--grep: 指定过滤条件, 类型: str, 可选wlan0(-1,-2,-3),wlan1(-1,-2,-3)
*命令说明*:
ifconfig
ifconfig | grep -A 12 iface1
*example*:
ap_show_ifconfig ap
ap_show_ifconfig ap --grep wlan0-1
*返回值*:
show出来的信息
'''
grep = ''
ret = ''
if argv:
cmd = argv.strip().split()
i = 0
while i < len(cmd):
tmpOpt = cmd[i]
if tmpOpt == '--grep':
i+=1
grep = cmd[i]
i+=1
ret = send_command_AP(alias, 'ifconfig',timeout)
if grep:
ret = send_command_AP(alias, 'ifconfig| grep %s' % grep,timeout)
return ret
#################################################################################################
#################################################################################################
def ap_show_brctl(alias, argv="", timeout=''):
''' *函数说明*: 查看brctl show
*参数说明*:
--grep: 指定过滤条件, 类型: str, 可选vlan
*命令说明*:
brctl show
brctl show |grep vlan
*example*:
ap_show_brctl ap
ap_show_brctl ap --grep vlan
*返回值*:
show出来的信息
'''
grep = ''
ret = ''
if argv:
cmd = argv.strip().split()
i = 0
while i < len(cmd):
tmpOpt = cmd[i]
if tmpOpt == '--grep':
i+=1
grep = cmd[i]
i+=1
ret = send_command_AP(alias, 'brctl show',timeout)
if grep:
ret = send_command_AP(alias, 'brctl show| grep %s' % grep,timeout)
return ret
#################################################################################################
#################################################################################################
def ap_show_staqos(alias, argv="", timeout=''):
''' *函数说明*: cat /etc/config/staqos
*参数说明*:
--grep: 指定过滤条件, 类型: str, 2gcfg0(1,2,3),5gcfg0(1,2,3)
*命令说明*:
cat /etc/config/staqos
cat /etc/config/staqos | grep -A 4 2gcfg0
*example*:
ap_show_ifconfig ap
ap_show_ifconfig ap --grep 2gcfg0
*返回值*:
show出来的信息
'''
grep = ''
ret = ''
if argv:
cmd = argv.strip().split()
i = 0
while i < len(cmd):
tmpOpt = cmd[i]
if tmpOpt == '--grep':
i+=1
grep = cmd[i]
i+=1
ret = send_command_AP(alias, 'cat /etc/config/staqos',timeout)
if grep:
ret = send_command_AP(alias, 'cat /etc/config/staqos | grep -A 4 %s' % grep,timeout)
return ret
#################################################################################################
#################################################################################################
def ap_show_network(alias, argv="", timeout=''):
''' *函数说明*: 查看ifconfig
*参数说明*:
--grep: 指定过滤条件, 类型: str
*命令说明*:
cat /etc/config/network |grep ap_proto
cat /etc/config/network
*example*:
ap_show_network ap
ap_show_network ap --grep ap_proto
*返回值*:
show出来的信息
'''
grep = ''
ret = ''
if argv:
cmd = argv.strip().split()
i = 0
while i < len(cmd):
tmpOpt = cmd[i]
if tmpOpt == '--grep':
i+=1
grep = cmd[i]
i+=1
ret = send_command_AP(alias, 'cat /etc/config/network',timeout)
if grep:
ret = send_command_AP(alias, 'cat /etc/config/network| grep %s' % grep,timeout)
return ret