List networks on a wireless interface

    CLI Examples:

        salt minion iwtools.scan wlp3s0
        salt minion iwtools.scan wlp3s0 list

def scan(iface, style=None):
    '''
    List networks on a wireless interface

    CLI Examples:

        salt minion iwtools.scan wlp3s0
        salt minion iwtools.scan wlp3s0 list
    '''
    if not _valid_iface(iface):
        raise SaltInvocationError(
            'The interface specified is not valid'
        )

    out = __salt__['cmd.run']('iwlist {0} scan'.format(iface))
    if 'Network is down' in out:
        __salt__['cmd.run']('ip link set {0} up'.format(iface))
        out = __salt__['cmd.run']('iwlist {0} scan'.format(iface))
    ret = {}
    tmp = {}
    for line in out.splitlines():
        if not line.strip():
            continue
        if 'Scan completed' in line:
            continue
        if line.strip().startswith('Cell'):
            comps = line.split(' - ')
            line = comps[1]
            if tmp:
                ret[tmp['Address']] = tmp
                tmp = {}
        comps = line.split(':')
        if comps[0].strip() == 'Address':
            # " is a valid character in SSIDs, but iwlist likes to wrap SSIDs in them
            comps[1] = comps[1].lstrip('"').rstrip('"')
        if comps[0].strip() == 'IE':
            if 'IE' not in tmp:
                tmp['IE'] = []
            tmp['IE'].append(':'.join(comps[1:]).strip())
        else:
            tmp[comps[0].strip()] = ':'.join(comps[1:]).strip()

    ret[tmp['Address']] = tmp

    if style == 'list':
        return ret.keys()

    return ret