def check_remote(url):
# TODO need a better solution
o = urlparse.urlparse(url)
host = o.netloc
while "@" in host:
host = host[host.find("@")+1:]
while ":" in host:
host = host[:host.find(":")]
cmd = list()
cmd.append("ping")
if platform.system().lower().startswith("win"):
cmd.append("-n")
cmd.append("1")
cmd.append("-w")
cmd.append("1000")
else:
cmd.append("-c1")
cmd.append("-t1")
cmd.append(host)
p = Popen(" ".join(cmd), stdout=PIPE, stderr=PIPE, shell=True)
out, err = p.communicate()
return len(err) == 0
评论列表
文章目录