def ping_url(ip_addr):
import subprocess
ping = subprocess.Popen(
["ping", "-c", "4", ip_addr],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
out, error = ping.communicate()
if out.lower().find("ms") > 0 and out.lower().find("ttl") > 0:
return 1
else:
return 0