#!/usr/bin/env python import math import sys import subprocess import re __author__ = 'cleef-zohevi' proc = subprocess.Popen('nmcli -p device wifi list | awk \'BEGIN {FS=" *"}{if ($8 >=70 && $8 != "") print $2,$4,$8}\'', shell=True, stdout=subprocess.PIPE, ) stdout_str = proc.communicate()[0] stdout_list=stdout_str.split('\n') #print stdout_list accesPointDict = {} myRunningList =['BSSID FREQ ACTIVE', '10:C3:7B:51:5B:98 2437 79', 'E8:FC:AF:A7:95:C9 2412 74', 'D8:EB:97:A7:0C:78 2412 75', 'D8:EB:97:A7:0C:7C 5825 73', 'C0:56:27:BA:3B:7D 2417 99', ''] print myRunningList[1].split(" ")[2] #def signalToDistance(frequency, signal): def dictionaryUpdater(): for items in myRunningList: accesPointDict[myRunningList[items].split(" ")[0]] = calculateDistance(int(myRunningList[items].split(" ")[1]), int) def calculateDistance(levelInDb, freqInMHz): distance= (27.55 - (20 * math.log(freqInMHz)) + abs(levelInDb)) / 20.0 return math.exp(10.0, distance);
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question