示例#1
0
def enable_network(id):
    try:
        wpa_cli.enable_network(id)
    except wpa_cli.WPAException:
        Printer(['Failed to', 'enable network'], i, o, skippable=True)
    else:
        wpa_cli.save_config()
        Printer(['Enabled network', str(id)], i, o, skippable=True)
示例#2
0
文件: main.py 项目: CRImier/pyLCI
def enable_network(id):
    try:
        wpa_cli.enable_network(id)
    except wpa_cli.WPAException:
        Printer(['Failed to', 'enable network'], i, o, skippable=True)
    else:
        wpa_cli.save_config()
        Printer(['Enabled network', str(id)], i, o, skippable=True)
示例#3
0
文件: main.py 项目: CRImier/pyLCI
def connect_to_network(network_info):
    #First, looking in the known networks
    configured_networks = wpa_cli.list_configured_networks()
    for network in configured_networks:
        if network_info['ssid'] == network['ssid']:
            Printer([network_info['ssid'], "known,connecting"], i, o, 1)
            wpa_cli.enable_network(network['network id'])
            wpa_cli.save_config()
            raise MenuExitException
    #Then, if it's an open network, just connecting
    if wpa_cli.is_open_network(network_info):
        network_id = wpa_cli.add_network()
        Printer(["Network is open", "adding to known"], i, o, 1)
        ssid = network_info['ssid']
        wpa_cli.set_network(network_id, 'ssid', '"{}"'.format(ssid))
        wpa_cli.set_network(network_id, 'key_mgmt', 'NONE')
        Printer(["Connecting to", network_info['ssid']], i, o, 1)
        wpa_cli.enable_network(network_id)
        wpa_cli.save_config()
        raise MenuExitException
    #Offering to enter a password
    else:
        input = CharArrowKeysInput(i, o, message="Password:"******"WiFi password enter UI element")
        password = input.activate()
        if password is None:
            return False
        network_id = wpa_cli.add_network()
        Printer(["Password entered", "adding to known"], i, o, 1)
        ssid = network_info['ssid']
        wpa_cli.set_network(network_id, 'ssid', '"{}"'.format(ssid))
        wpa_cli.set_network(network_id, 'psk', '"{}"'.format(password))
        Printer(["Connecting to", network_info['ssid']], i, o, 1)
        wpa_cli.enable_network(network_id)
        wpa_cli.save_config()
        raise MenuExitException
示例#4
0
文件: main.py 项目: blitzaxt/ZPUI
def connect_to_network(network_info):
    #First, looking in the known networks
    configured_networks = wpa_cli.list_configured_networks()
    for network in configured_networks:
        if network_info['ssid'] == network['ssid']:
            Printer([network_info['ssid'], "known,connecting"], i, o, 1)
            wpa_cli.enable_network(network['network id'])
            wpa_cli.save_config()
            raise MenuExitException
    #Then, if it's an open network, just connecting
    if wpa_cli.is_open_network(network_info):
        network_id = wpa_cli.add_network()
        Printer(["Network is open", "adding to known"], i, o, 1)
        ssid = network_info['ssid']
        wpa_cli.set_network(network_id, 'ssid', '"{}"'.format(ssid))
        wpa_cli.set_network(network_id, 'key_mgmt', 'NONE')
        Printer(["Connecting to", network_info['ssid']], i, o, 1)
        wpa_cli.enable_network(network_id)
        wpa_cli.save_config()
        raise MenuExitException
    #Offering to enter a password
    else:
        input = NumpadCharInput(i, o, message="Password:"******"WiFi password enter UI element")
        password = input.activate()
        if password is None:
            return False
        network_id = wpa_cli.add_network()
        Printer(["Password entered", "adding to known"], i, o, 1)
        ssid = network_info['ssid']
        wpa_cli.set_network(network_id, 'ssid', '"{}"'.format(ssid))
        wpa_cli.set_network(network_id, 'psk', '"{}"'.format(password))
        Printer(["Connecting to", network_info['ssid']], i, o, 1)
        wpa_cli.enable_network(network_id)
        wpa_cli.save_config()
        raise MenuExitException