31 lines
605 B
Python
31 lines
605 B
Python
#!/usr/bin/env python
|
|
|
|
import re
|
|
import time
|
|
import sys
|
|
import os
|
|
import subprocess
|
|
|
|
signal = 0
|
|
avg = 0
|
|
freq = 5
|
|
|
|
for i in range(freq):
|
|
time.sleep(1)
|
|
line = subprocess.check_output(["echo $(/sbin/iwconfig wlan0 | grep Signal)"], shell=True)
|
|
sys.stdout.flush()
|
|
try:
|
|
found = re.search('Signal level=(.+?) dBm', line).group(1)
|
|
signal += int(found)
|
|
except AttributeError:
|
|
# Value not found...
|
|
print("Value not found. Stopping test.")
|
|
exit()
|
|
print found
|
|
sys.stdout.flush()
|
|
|
|
avg = (signal/freq)
|
|
print("Average:")
|
|
print(avg)
|
|
sys.stdout.flush()
|