import os
import time
import gateway_ping
import phone_home

def wifi_ping():
    # Pings google DNS from interface wlan0 (wifi)
    hostname = "8.8.8.8"
    interface = "wlan0"
    response = os.system("ping -c 4 -I " + interface + " " + hostname)

    if response == 0:
        status = 'Up'
        print(status)
    else:
        status = 'Down'
        # if no response is recieved ping the default gateway
        gateway_ping.run() 
        # phone_home.phone_home()
    return status
eth_ping()

# Run function for entire script (will have a delay of 30 minutes between executions)
def run():
    while(True):
        print(eth_ping())
        time.sleep(3000)