connectivity-check 308 Bytes
Newer Older
1
2
3
4
5
6
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import socket


7
def is_connected(host="1.1.1.1"):
8
    try:
9
        socket.create_connection((host, 53), timeout=4)
10
11
12
13
14
15
16
17
        return True
    except Exception:
        pass
    return False


if __name__ == "__main__":
    print("yes" if is_connected() else "no")