Merge branch 'master' of github.com:zyphlar/pinger
This commit is contained in:
commit
af5dfb34e0
25
ping.inc.py
25
ping.inc.py
|
@ -97,8 +97,13 @@ class Util:
|
||||||
out, error = ssid.communicate()
|
out, error = ssid.communicate()
|
||||||
m = re.search(r'yes:(.*)', out)
|
m = re.search(r'yes:(.*)', out)
|
||||||
result = m.group(1)
|
result = m.group(1)
|
||||||
elif platform.system() == "Macintosh":
|
elif platform.system() == "Darwin":
|
||||||
foo
|
ssid = subprocess.Popen(["/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport","-I"],
|
||||||
|
stdout = subprocess.PIPE,
|
||||||
|
stderr = subprocess.PIPE
|
||||||
|
)
|
||||||
|
out, error = ssid.communicate()
|
||||||
|
result = out
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -117,8 +122,20 @@ class Util:
|
||||||
output = {'loss':-1, 'rtt_avg':-1};
|
output = {'loss':-1, 'rtt_avg':-1};
|
||||||
else:
|
else:
|
||||||
output = {'loss':lossResult.group(1), 'rtt_avg':rttAvgResult.group(1)};
|
output = {'loss':lossResult.group(1), 'rtt_avg':rttAvgResult.group(1)};
|
||||||
elif platform.system() == "Macintosh":
|
elif platform.system() == "Darwin": # Macintosh
|
||||||
foo
|
ping = subprocess.Popen(
|
||||||
|
["ping", "-c", "5", target],
|
||||||
|
stdout = subprocess.PIPE,
|
||||||
|
stderr = subprocess.PIPE
|
||||||
|
)
|
||||||
|
pingOut, error = ping.communicate()
|
||||||
|
# print out
|
||||||
|
lossResult = re.search(r' ([0-9]+)% packet loss', pingOut, re.MULTILINE)
|
||||||
|
rttAvgResult = re.search(r' = [\d\.]+/([\d\.]+)/[\d\.]+/[\d\.]+', pingOut, re.MULTILINE)
|
||||||
|
if pingError:
|
||||||
|
output = {'loss':-1, 'rtt_avg':-1};
|
||||||
|
else:
|
||||||
|
output = {'loss':lossResult.group(1), 'rtt_avg':rttAvgResult.group(1)};
|
||||||
return output
|
return output
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in New Issue
Block a user