I have this code below that prints out the Link Quality & Signal Level of WiFi connection. I'm trying to store the data retrieved into a variables so I could process further but I'm stuck having no idea how to do so.
while True:
cmd = subprocess.Popen('iwconfig %s' % args.interface, shell=True,
stdout=subprocess.PIPE)
for line in cmd.stdout:
if 'Link Quality' in line:
print line.lstrip(' '),
elif 'Not-Associated' in line:
print 'No signal'
time.sleep(1)
Example of the output
Link Quality=63/70 Signal level=-47 dBm
Instead of printing, save the result into data structure, for examle into list like following: