def close_wizard_click_othermenu(self):
     #点击关闭按钮
     SWControl.close_wizard(self)
     #进入接入点确定没有设置向导窗口
     SWControl.menu_css(self,u"接入点","Access Points")
     result = SWControl.check_wizard(self)
     return result
    def AP_status(self,master_ap,slave_ap1,slave_ap2):
        result = []
        n = SWBusiness.get_country_code(self)
        #点击页面上的问号开启设置向导
        SWControl.SW_menu(self)
        #点击两次下一步
        for i in range(2-n):
            SWControl.nextstep(self)
        time.sleep(30)
        result1 = SWControl.get_APs_text(self)
        Master_AP = master_ap.upper()
        Slave_ap1 = slave_ap1.upper()
        Slave_ap2 = slave_ap2.upper()
        print Master_AP,result1
        if (Master_AP in result1) and (Slave_ap1 in result1) and (Slave_ap2 in result1):
            result.append(True)
        else:
            result.append(False)

        #获取APs页面中没有配对的元素的disabled属性
        result2 = SWControl.get_APs_unpair(self)
        #如果有disable属性为true的,则返回True
        if 'true' in result2:
            result.append(True)
        else:
            result.append(False)

        return result
 def wifi_status(self):
     n = SWBusiness.get_country_code(self)
     #打开设置向导
     SWControl.SW_menu(self)
     #点击三次下一步
     for i in range(3-n):
         SWControl.nextstep(self)
     #获取wifi的状态
     #输出:true:被选中,None:没被选中
     result = SWControl.get_wifi_status(self)
     return result
 def check_default_ssid(self,master_ap):
     n = SWBusiness.get_country_code(self)
     #取得应该的ssid
     tmp = SWBusiness.default_ssid(self,master_ap)
     #打开设置向导
     SWControl.SW_menu(self)
     #点击三次下一步
     for i in range(3-n):
         SWControl.nextstep(self)
     #获取SSID
     result = SWControl.get_ssid(self)
     print tmp,result
     if result == tmp:
         return True
     else:
         return False
 def add_slave_ap(self,slave_ap):
     n = SWBusiness.get_country_code(self)
     #小写转换为大写
     Slave_ap = slave_ap.upper()
     #打开设置向导
     SWControl.SW_menu(self)
     #点击三次下一步
     for i in range(3-n):
         SWControl.nextstep(self)
     #1.0.2.94已调整到每次配对后,设备自动在已添加的设备中
     #SWControl.add_NG(self)
     #获取已添加设备的mac
     result2 = SWControl.get_member_devices(self)
     print Slave_ap,result2
     if Slave_ap in result2:
         return True
     else:
         return False
 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 default_devices(self,slave_ap,master_ap):
     n = SWBusiness.get_country_code(self)
     #小写转换为大写
     Slave_ap = slave_ap.upper()
     Master_ap =master_ap.upper()
     #打开设置向导
     SWControl.SW_menu(self)
     #点击三次下一步
     for i in range(3-n):
         SWControl.nextstep(self)
     #获取可添加设备的mac
     #result1 = SWControl.get_available_devices(self)
     #获取已添加设备的mac----1.0.2.94已调整到每次配对后,设备自动在已添加的设备中
     result2 = SWControl.get_member_devices(self)
     print Slave_ap,Master_ap,result2
     if (Slave_ap and Master_ap) in result2:
         return True
     else:
         return False
 def disable_wifi(self,ssid,wlan):
     n = SWBusiness.get_country_code(self)
     #打开设置向导
     SWControl.SW_menu(self)
     #点击三次下一步
     for i in range(3-n):
         SWControl.nextstep(self)
     ##设置wifi的状态:disalbe/enable
     SWControl.set_wifi_status(self)
     #设置SSID
     #SWControl.ssid(self,ssid)
     #设置wpa的密码
     #SWControl.wpa_key(self,key)
     SWControl.nextstep(self)
     time.sleep(120)
     print "disable wifi in setupwizard successfully!"
     #扫描到ssid返回True
     result = SWControl.ssid_scan_result(self,ssid,wlan)
     print result
     return result
 def unpair_slave_ap(self,host,user,pwd):
     n = SWBusiness.get_country_code(self)
     #打开设置向导
     SWControl.SW_menu(self)
     #点击两次下一步
     for i in range(2-n):
         SWControl.nextstep(self)
     #只有一个slave时,解除配对的设备
     SWControl.unpair(self)
     SWControl.notice_ok(self)
     time.sleep(200)
     #登录AP后台取出管理员密码,判断slave ap是否恢复出厂设置
     ssh = SSH(host,pwd)
     result = ssh.ssh_cmd(user,"uci show grandstream.general.admin_password")
     if "='admin'" in result:
         return True
     else:
         return False
 def del_ap(self,slave_ap,host,user,pwd):
     n = SWBusiness.get_country_code(self)
     #再次打开设置向导
     SWControl.SW_menu(self)
     #点击三次下一步
     for i in range(3-n):
         SWControl.nextstep(self)
     #设备管理,在已添加的设备中删除特定的设备
     SWControl.del_NG_special(self,slave_ap)
     SWControl.nextstep(self)
     time.sleep(80)
     #登录slave ap确认没有wifi接口
     ssh = SSH(host,pwd)
     result = ssh.ssh_cmd(user,"ifconfig")
     if 'wifi0' in result:
         return False
     else:
         return True
 def pair_slaveAP(self,mac):
     n = SWBusiness.get_country_code(self)
     #打开设置向导
     SWControl.SW_menu(self)
     #点击两次下一步
     for i in range(2-n):
         SWControl.nextstep(self)
     #点击配对
     SWControl.pair(self,mac)
     time.sleep(80)
     #获取APs页面的状态信息
     result1 = SWControl.get_APs_status(self)
     print result1
     if (u"在线" or 'Online') in result1:
         return True
     else:
         return False
    def othermenu_click(self):
        result = []

        #进入接入点
        SWControl.menu_css(self,u"接入点","Access Points")
        ##点击页面上的问号开启设置向导
        SWControl.SW_menu(self)
        #检查登录web界面,判断是否会显示向导页面
        result11 = SWControl.check_wizard(self)
        #下次不再显示是否被选中
        result12 = SWControl.get_hidenexttime(self)
        SWControl.close_wizard(self)
        if result11 == True and result12 =="true":
            result.append(True)
        else:
            result.append(False)

        #进入SSIDs
        SWControl.menu_css(self,u"SSIDs","SSIDs")
        ##点击页面上的问号开启设置向导
        SWControl.SW_menu(self)
        result21 = SWControl.check_wizard(self)
        #下次不再显示是否被选中
        result22 = SWControl.get_hidenexttime(self)
        SWControl.close_wizard(self)
        if result21 == True and result22 =="true":
            result.append(True)
        else:
            result.append(False)
        #进入客户端
        SWControl.menu_css(self,u"客户端","Clients")
        ##点击页面上的问号开启设置向导
        SWControl.SW_menu(self)
        result31 = SWControl.check_wizard(self)
        #下次不再显示是否被选中
        result32 = SWControl.get_hidenexttime(self)
        SWControl.close_wizard(self)
        if result31 == True and result32 =="true":
            result.append(True)
        else:
            result.append(False)
        #进入系统设置
        SWControl.menu_css(self,u"系统设置","System Settings")
        ##点击页面上的问号开启设置向导
        SWControl.SW_menu(self)
        result41 = SWControl.check_wizard(self)
        #下次不再显示是否被选中
        result42 = SWControl.get_hidenexttime(self)
        SWControl.close_wizard(self)
        if result41 == True and result42 =="true":
            result.append(True)
        else:
            result.append(False)
        return result
 def complete_backup(self,ssid,key,wlan,slave_mac2):
     n = SWBusiness.get_country_code(self)
     #打开设置向导
     SWControl.SW_menu(self)
     #点击两次下一步
     for i in range(2-n):
         SWControl.nextstep(self)
     #点击配对
     SWControl.pair(self,slave_mac2)
     time.sleep(20)
     #点击下一步
     SWControl.nextstep(self)
     #设置SSID
     SWControl.ssid(self,ssid)
     #设置wpa的密码
     SWControl.wpa_key(self,key)
     #1.0.2.94已调整到每次配对后,设备自动在已添加的设备中
     #设备管理,只有一个设备时,只添加一个设备
     #SWControl.add_NG(self)
     SWControl.nextstep(self)
     time.sleep(120)
     print "run setupwizard,pair slave ap,set ssid and key successfully!"
     #无线网卡连接该ssid,返回连接的结果
     result = SWControl.connect_WPA_AP(self,ssid,key,wlan)
     #使无线网卡获取IP地址
     #SWControl.dhcp_wlan(self,wlan)
     if ssid in result:
         return True
     else:
         return False
 def enable_wifi(self,ssid,key,wlan):
     n = SWBusiness.get_country_code(self)
     #打开设置向导
     SWControl.SW_menu(self)
     #点击三次下一步
     for i in range(3-n):
         SWControl.nextstep(self)
     ##设置wifi的状态:disalbe/enable
     SWControl.set_wifi_status(self)
     #设置SSID
     SWControl.ssid(self,ssid)
     #设置wpa的密码
     SWControl.wpa_key(self,key)
     SWControl.nextstep(self)
     time.sleep(180)
     #扫描到ssid返回True
     result = SWControl.ssid_scan_result_backup(self,ssid,wlan)
     print result
     return result
 def __init__(self,driver):
     #继承SWControl类的属性和方法
     SWControl.__init__(self,driver)