# Path: dbsync/client/net.py
# def head_request(server_url):
#     """
#     Sends a HEAD request to *server_url*.
# 
#     Returns a pair of (code, reason).
#     """
#     if not server_url.startswith("http://") and \
#             not server_url.startswith("https://"):
#         server_url = "http://" + server_url
#     try:
#         r = requests.head(server_url, timeout=default_timeout)
#         return (r.status_code, r.reason)
# 
#     except requests.exceptions.RequestException as e:
#         raise NetworkError(*e.args)
# 
#     except Exception as e:
#         raise NetworkError(*e.args)
# 
# class NetworkError(Exception):
#     pass


from dbsync.client.net import head_request, NetworkError
"""
Ping the server.

The ping procedures are used to quickly diagnose the internet
connection and server status from the client application.
"""



def isconnected(ping_url):
    """Whether the client application is connected to the Internet."""
    try:
        head_request(ping_url)
        return True
    except NetworkError:
        return False


def isready(ping_url):
    """Whether the server is ready to receive synchronization
    requests."""
    try:

# Path: dbsync/client/net.py
# def head_request(server_url):
#     """
#     Sends a HEAD request to *server_url*.
# 
#     Returns a pair of (code, reason).
#     """
#     if not server_url.startswith("http://") and \
#             not server_url.startswith("https://"):
#         server_url = "http://" + server_url
#     try:
#         r = requests.head(server_url, timeout=default_timeout)
#         return (r.status_code, r.reason)
# 
#     except requests.exceptions.RequestException as e:
#         raise NetworkError(*e.args)
# 
#     except Exception as e:
#         raise NetworkError(*e.args)
# 
# class NetworkError(Exception):
#     pass


# Path: dbsync/client/ping.py
from dbsync.client.net import head_request, NetworkError

"""
Ping the server.

The ping procedures are used to quickly diagnose the internet
connection and server status from the client application.
"""



def isconnected(ping_url):
    """Whether the client application is connected to the Internet."""
    try:
        head_request(ping_url)
        return True
    except NetworkError:
        return False


def isready(ping_url):
    """Whether the server is ready to receive synchronization
    requests."""
    try:

        code, reason = head_request(ping_url)