Merge branch 'master' of github.com:zyphlar/pinger

This commit is contained in:
Will Bradley 2017-03-13 04:13:21 -07:00
commit af5dfb34e0

View File

@ -97,8 +97,13 @@ class Util:
out, error = ssid.communicate()
m = re.search(r'yes:(.*)', out)
result = m.group(1)
elif platform.system() == "Macintosh":
foo
elif platform.system() == "Darwin":
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
@staticmethod
@ -117,8 +122,20 @@ class Util:
output = {'loss':-1, 'rtt_avg':-1};
else:
output = {'loss':lossResult.group(1), 'rtt_avg':rttAvgResult.group(1)};
elif platform.system() == "Macintosh":
foo
elif platform.system() == "Darwin": # Macintosh
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
#