Esempio n. 1
0
    def check_jump_to_No_auth_portal_backup(self, ssid, password, wlan, eth,
                                            wifi_encryption):
        #无线网卡释放ip地址
        CPControl.dhcp_release_wlan(self, wlan)
        #禁用有线网卡
        CPControl.wlan_disable(self, eth)
        time.sleep(60)
        #使用无线网卡连接group0的ssid
        if wifi_encryption == "open":
            CPControl.connect_NONE_AP(self, ssid, wlan)
        elif wifi_encryption == "wep":
            CPControl.connect_WEP_AP(self, ssid, password, wlan)
        elif wifi_encryption == "wpa":
            CPControl.connect_WPA_AP(self, ssid, password, wlan)
        elif wifi_encryption == "wpa_hiddenssid":
            CPControl.connect_WPA_hiddenssid_AP(self, ssid, password, wlan)
        elif wifi_encryption == "802.1x":
            CPControl.connect_8021x_AP(self, ssid,
                                       data_basic['radius_usename'],
                                       data_basic['radius_password'], wlan)

        #再次禁用有线网卡--防止无线网卡的多次连接时会重启全部网络导致有限网卡再次开启
        CPControl.wlan_disable(self, eth)
        #循环三次检查无线网卡是否能够上网
        for i in range(3):
            #无线网卡释放ip地址
            CPControl.dhcp_release_wlan(self, wlan)
            #无线网卡再次获取ip地址
            CPControl.dhcp_wlan(self, wlan)
            CPControl.move_resolv(self)
            #如果不能访问网络
            tmp = CPControl.get_ping(self, "www.qq.com")
            if tmp == 0:
                break
            else:
                "check wlan card can access internet or not,again."
        #打开http的页面http://www.qq.com
        redirect_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
        print "Access tencent webpage, jump to %s webpage" % redirect_title
        #无线网卡释放ip地址
        CPControl.dhcp_release_wlan(self, wlan)
        #断开无线连接
        CPControl.disconnect_ap(self)
        #启用有线网卡
        CPControl.wlan_enable(self, eth)
        print redirect_title
        if redirect_title == "gatewayname Entry":
            return True
        else:
            return False
Esempio n. 2
0
    def access_No_auth_portal(self, ssid, password, wlan, eth,
                              wifi_encryption):
        #无线网卡释放ip地址
        CPControl.dhcp_release_wlan(self, wlan)
        #禁用有线网卡
        CPControl.wlan_disable(self, eth)
        time.sleep(30)
        #使用无线网卡连接group0的ssid
        if wifi_encryption == "open":
            CPControl.connect_NONE_AP(self, ssid, wlan)
        elif wifi_encryption == "wep":
            CPControl.connect_WEP_AP(self, ssid, password, wlan)
        elif wifi_encryption == "wpa":
            CPControl.connect_WPA_AP(self, ssid, password, wlan)
        elif wifi_encryption == "wpa_hiddenssid":
            CPControl.connect_WPA_hiddenssid_AP(self, ssid, password, wlan)
        elif wifi_encryption == "802.1x":
            CPControl.connect_8021x_AP(self, ssid,
                                       data_basic['radius_usename'],
                                       data_basic['radius_password'], wlan)

        #再次禁用有线网卡--防止无线网卡的多次连接时会重启全部网络导致有限网卡再次开启
        CPControl.wlan_disable(self, eth)
        #循环三次检查无线网卡是否能够上网
        for i in range(3):
            #无线网卡释放ip地址
            CPControl.dhcp_release_wlan(self, wlan)
            #无线网卡再次获取ip地址
            CPControl.dhcp_wlan(self, wlan)
            CPControl.move_resolv(self)
            #如果不能访问网络
            tmp = CPControl.get_ping(self, "www.qq.com")
            if tmp == 0:
                break
            else:
                print "check wlan card can access internet or not,again."
        #打开http的页面http://www.qq.com
        portal_title = CPBusiness.wait_for_title(self, "http://www.qq.com")
        print "Access tencent webpage first, goin to %s" % portal_title
        #免认证页面点击同意,然后再点击登录
        redirect_title = CPBusiness.enter_default_portal(self)
        print "click agree, goin to %s" % redirect_title
        return portal_title, redirect_title