コード例 #1
0
ファイル: wifi.py プロジェクト: KanoComputing/os-diagnostics
def get_wireless_status(iface='wlan0'):
    out, _ = run_cmd('sudo iwconfig {}'.format(iface))

    status = {}

    status['quality'] = ', '.join(re.findall(r'Link Quality=(\d+/\d\d)', out))
    status['rate'] = ', '.join(re.findall(r'Bit Rate=(.* Mb/s)', out))
    status['essid'] = ', '.join(re.findall(r'ESSID:"(.*)"', out))

    iwlist, _ = run_cmd('/sbin/iwlist {} channel'.format(iface))

    status['channel'] = ', '.join(
        re.findall(r'Current Frequency.+\(Channel (\d+)\)', iwlist))

    iwlist_scan, _ = run_cmd('/sbin/iwlist {} scan'.format(iface))
    if re.findall(r'WPA2', iwlist_scan):
        status['encryption'] = 'WPA2'
    elif re.findall(r'WPA', iwlist_scan):
        status['encryption'] = 'WPA'
    elif re.findall(r'WEP', iwlist_scan):
        status['encryption'] = 'WEP'
    else:
        status['encryption'] = 'None'

    return out, status
コード例 #2
0
def get_audio_routing():

    # first log alsa config to log file only
    cmd = "amixer contents"
    stdout, stderr = run_cmd(cmd)

    log(stdout, only_file=True)

    # get specific settings
    cmd = "amixer -c 0 cget name='PCM Playback Route'"
    stdout, stderr = run_cmd(cmd)

    try:
        lines = stdout.split('\n')
        val = lines[2].split('=')[1]
        log("audio route: " + val)
        route = val
    except:
        log("failed to parse audio route")
        route = None

    stdout, stderr = run_cmd('vcgencmd get_config  hdmi_ignore_edid_audio')
    log(stdout)

    stdout, stderr = run_cmd('vcgencmd get_config  hdmi_drive')
    log(stdout)

    return route
コード例 #3
0
ファイル: wifi.py プロジェクト: KanoComputing/os-diagnostics
def get_dns_settings():
    out, _ = run_cmd('cat /etc/resolv.conf')

    nameserver_regex = re.compile(r'^nameserver (.+)$', re.MULTILINE)
    nameservers = nameserver_regex.findall(out)

    return ', '.join(nameservers)
コード例 #4
0
ファイル: wifi.py プロジェクト: KanoComputing/os-diagnostics
def get_routing_table():
    out, _ = run_cmd('ip route')

    return out
コード例 #5
0
ファイル: wifi.py プロジェクト: KanoComputing/os-diagnostics
def get_ip_address():
    out, _ = run_cmd('hostname -I')

    return ', '.join(out.strip().split(' '))
コード例 #6
0
def set_audio_routing(where):
    cmd = "amixer -c 0 cset name='PCM Playback Route' {}".format(where)
    stdout, stderr = run_cmd(cmd)
コード例 #7
0
def run_speaker_test(where):
    log('Testing Speaker: {}'.format(where))
    cmd = "speaker-test -r 48000 -f 600 -t sine -s 1"
    run_cmd(cmd)
    x = raw_input("What did you hear? ")
    log(x, only_file=True)