示例#1
0
文件: G54S.py 项目: peterwyj/WSDT
def G54S(config):
    ie = PAMIE()
    wga = winGuiAuto
    mp = cModalPopUp
    ie.navigate("http://" + IP + "/advance/advance-lan-wireless.htm")
    login = wga.findTopWindow(wantedText="Connect to " + IP)
    credential = wga.findControl(login, wantedClass="SysCredential")
    user1 = wga.findControl(credential, wantedClass="ComboBoxEx32")
    user2 = wga.findControl(user1, wantedClass="ComboBox")
    user3 = wga.findControl(user2, wantedClass="Edit")
    wga.setEditText(user3, username)

    ## If password is not null,enter password by win32api.keybd_event
    ## First enter Alt+p
    win32api.keybd_event(18, 0, 0, 0)
    win32api.keybd_event(80, 0, 0, 0)
    win32api.keybd_event(18, 0, win32con.KEYEVENTF_KEYUP, 0)
    win32api.keybd_event(80, 0, win32con.KEYEVENTF_KEYUP, 0)

    ##Then enter password
    """win32api.keybd_event(82,0,0,0)
    win32api.keybd_event(82,0,win32con.KEYEVENTF_KEYUP,0)
    win32api.keybd_event(79,0,0,0)
    win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0)
    win32api.keybd_event(79,0,0,0)
    win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0)
    win32api.keybd_event(84,0,0,0)
    win32api.keybd_event(84,0,win32con.KEYEVENTF_KEYUP,0)
    time.sleep(10)"""

    OKButton = wga.findControl(login, wantedClass="Button", wantedText="OK")
    wga.clickButton(OKButton)

    ie.navigate("http://" + IP + "/advance/ad-lan-wireless_g.htm")
    ie.radioButtonSet("wl_radio", "1", checked=True)
    if config["wirelessmode"] == "802.11b only":
        wirelessmode = "11b-Only"
    elif config["wirelessmode"] == "802.11g only":
        wirelessmode = "11g-Only"
    elif config["wirelessmode"] == "802.11b/g":
        wirelessmode = "Mixed"
    ie.listBoxSelect("wl_gmode", wirelessmode)

    SSID = config["SSID"]
    ie.textBoxSet("wl_ssid_input", SSID)

    if config["autochannel"] == "Disable":
        ie.checkBoxSet("wl_channel_auto", 0)
    else:
        ie.checkBoxSet("wl_channel_auto", 1)

    channel = config["channel"]
    ie.listBoxSelect("wl_channel", "Channel " + channel)
    ie.buttonClick("Apply")
    time.sleep(10)
    ie.navigate("http://" + IP + "/advance/ad-lan-wireless_sec_g.htm")
    ie.radioButtonSet("wl_closed", "0", checked=True)

    encryption = config["encryption"]
    if encryption == "None":
        ie.radioButtonSet("wl_wep", "off", checked=True)
    elif encryption == "WEP":
        ie.radioButtonSet("wl_wep", "restricted", checked=True)
        keyindex = config["keyindex"]
        keytype = config["keytype"]
        wepkey = config["wepkey"]
        ie.radioButtonSet("wl_key", keyindex, checked=True)
        ie.listBoxSelect("wep_ascii_select" + keyindex, keytype)
        ie.textBoxSet("wl_key" + keyindex, wepkey)
    elif encryption == "TKIP":
        ie.radioButtonSet("wl_wep", "tkip", checked=True)
        ie.textBoxSet("wl_wpa_psk", config["passphrase"])
    elif encryption == "AES":
        ie.radioButtonSet("wl_wep", "aes", checked=True)
        ie.textBoxSet("wl_wpa_psk", config["passphrase"])

    ie.buttonClick("Apply")
    time.sleep(10)