def get_country_code(self): #登录web页面获取DUT的hostname DUT_hostname = SWControl.get_DUT_hostname(self) data_basic = data.data_basic() data_login = data.data_login() ssh = SSH(data_basic['DUT_ip'],data_login['all']) tmp1 = ssh.ssh_cmd(data_basic['sshUser'],"ubus call controller.core status | grep part_number") tmp = tmp1.split("\"")[3][-4] if DUT_hostname == "GWN7610": #如果是USA,返回1 if tmp == "1": print "The AP is USA product!" return 1 #如果是WORLD,返回0 elif tmp == "6": print "The AP is WORLD product!" return 0 else: print "PN value is not correct!" return None elif DUT_hostname == "GWN7600": #如果是USA,返回1 if tmp == "5": print "The AP is USA product!" return 1 #如果是WORLD,返回0 elif tmp == "7": print "The AP is WORLD product!" return 0 else: print "PN value is not correct!" return None elif DUT_hostname == "GWN7600LR": #如果是USA,返回1 if tmp == "1": print "The AP is USA product!" return 1 #如果是WORLD,返回0 elif tmp == "2": print "The AP is WORLD product!" return 0 else: print "PN value is not correct!" return None elif DUT_hostname == "GWN7002W": #如果是USA,返回1 if tmp == "8": print "The AP is USA product!" return 1 #如果是WORLD,返回0 elif tmp == "9": print "The AP is WORLD product!" return 0 else: print "PN value is not correct!" return None
def set_username(self): try: WebDriverWait(self.driver,120).until(lambda x:self.driver.find_element_by_id("username")) except: data_basic = data.data_basic() PublicControl.wlan_enable(self,data_basic['lan_pc']) PublicControl.dhcp_release_wlan(self,data_basic['wlan_pc']) time.sleep(60) #self.driver.close() self.driver.refresh() self.driver.implicitly_wait(20) finally: username_element = self.driver.find_element_by_id("username") WebDriverWait(self.driver,120).until(lambda x:username_element) username_element.clear() username_element.send_keys(self.username)
def check_slaveAP_upload_backup(self, ssid, password, wlan, lan, mac): #无线网卡连接master ap OVControl.connect_DHCP_WPA_AP(self, ssid, password, wlan) #禁用有线网卡 OVControl.wlan_disable(self, lan) i = 0 while i < 3: tmp = OVControl.get_ping(self, d['iperf_ip']) if tmp == 0: #描述:使用iperf3进行上传 tmp1 = subprocess.call("iperf3 -c %s -t180 -w5M" % d['iperf_ip'], shell=True) print tmp1 break else: OVControl.wlan_enable(self, lan) OVControl.dhcp_release_wlan(self, wlan) OVControl.dhcp_wlan(self, wlan) OVControl.wlan_disable(self, lan) print "run iperf3 fail,try %s again!" % (i + 1) i = i + 1 continue #启用有线网卡 OVControl.wlan_enable(self, lan) #使无线网卡释放IP地址 OVControl.dhcp_release_wlan(self, wlan) self.driver.refresh() self.driver.implicitly_wait(10) time.sleep(6) #登录AP data_basic = data.data_basic() data_login = data.data_login() Lg = LoginBusiness(self.driver) Lg.login(data_basic['superUser'], data_login['all']) time.sleep(300) try: #获取master ap的上传流量 result3 = OVControl.get_ap_upflow(self, mac) result1 = result3.strip("MB").strip("KB").strip("B").strip("GB") result2 = int(float(result1)) print result3, result2 return result3, result2 except: print u"在overview页面的Top AP上没有找到该AP!" return "0MB", 0
def set_username_backup(self): """ 输入用户名--backup """ try: self.driver.find_element_by_class_name("uname") except: data_basic = data.data_basic() PublicControl.wlan_enable(self, data_basic['lan_pc']) PublicControl.dhcp_release_wlan(self, data_basic['wlan_pc']) PublicControl.dhcp_wlan(self, data_basic['lan_pc']) time.sleep(60) #self.driver.close() self.driver.refresh() self.driver.implicitly_wait(20) time.sleep(60) finally: username_element = self.driver.find_element_by_class_name("uname") username_element.clear() username_element.send_keys(self.username)
def set_username(self): """ 输入用户名 """ try: WebDriverWait(self.driver, 120).until( lambda x: self.driver.find_element_by_class_name("uname")) except: data_basic = data.data_basic() PublicControl.wlan_enable(self, data_basic['lan_pc']) PublicControl.dhcp_release_wlan(self, data_basic['wlan_pc']) #指定有线网卡的固定ip--能够访问ap的webpage PublicControl.set_eth_ip(self, data_basic['lan_pc'], data_basic['static_PC_ip']) time.sleep(60) #self.driver.close() self.driver.refresh() self.driver.implicitly_wait(20) finally: time.sleep(4) username_element = self.driver.find_element_by_class_name("uname") username_element.clear() username_element.send_keys(self.username)
#coding=utf-8 #作者:曾祥卫 #时间:2017.03.29 #描述:GWN76xx客户端的业务层 from clients_control import ClientsControl from connect.ssh import SSH from data import data from login.login_business import LoginBusiness import time data_basic = data.data_basic() class ClientsBusiness(ClientsControl): def __init__(self, driver): #继承ClientsControl类的属性和方法 ClientsControl.__init__(self, driver) #判断无线客户端mac是否在列表中 def check_client(self, wlan): try: #点击客户端菜单 ClientsControl.clients_menu(self) self.driver.refresh() self.driver.implicitly_wait(30) #获取无线客户端的mac mac = ClientsControl.get_wlan_mac(self, wlan) #将mac地址去掉冒号,转换为小写 mac1 = mac.split(":") mac = ''.join(mac1)