# Path: lib/network.py
# URL = 'http://www.google.com'
# def is_internet_on(method=1, debug=False):
# def get_my_external_ip():
# def ping(host, cnt=1):
# def fping(host, cnt=1):
# 
# Path: lib/audio.py
# def play(audio_file, background=False, debug=False):
#     """Play an audio file with mplayer."""
#     cmd = '{player} "{audio}"'.format(player=cfg.PLAYER, audio=audio_file)
#     if not debug:
#         cmd += ' 1>/dev/null 2>&1'
#     if background:
#         cmd += ' &'
#     os.system(cmd)


import os
import socket
from pathlib import Path
from time import sleep
from lib import network
from lib.audio import play
#!/usr/bin/env python3

"""
Play a sound when the Internet connection is back.
"""



ROOT = os.path.dirname(os.path.abspath(__file__))
TIMEOUT = 3
AUDIO = str(Path(ROOT, "assets", "alert.wav"))


def main():
    cnt = 0
    while True:
        cnt += 1
        print('# testing...' if cnt == 1 else '# test again...')
        if network.is_internet_on(method=3):
            print('# Whoa, your net is alive!')

# Path: lib/network.py
# URL = 'http://www.google.com'
# def is_internet_on(method=1, debug=False):
# def get_my_external_ip():
# def ping(host, cnt=1):
# def fping(host, cnt=1):
# 
# Path: lib/audio.py
# def play(audio_file, background=False, debug=False):
#     """Play an audio file with mplayer."""
#     cmd = '{player} "{audio}"'.format(player=cfg.PLAYER, audio=audio_file)
#     if not debug:
#         cmd += ' 1>/dev/null 2>&1'
#     if background:
#         cmd += ' &'
#     os.system(cmd)


# Path: is_net_back.py
import os
import socket
from pathlib import Path
from time import sleep
from lib import network
from lib.audio import play

#!/usr/bin/env python3

"""
Play a sound when the Internet connection is back.
"""



ROOT = os.path.dirname(os.path.abspath(__file__))
TIMEOUT = 3
AUDIO = str(Path(ROOT, "assets", "alert.wav"))


def main():
    cnt = 0
    while True:
        cnt += 1
        print('# testing...' if cnt == 1 else '# test again...')
        if network.is_internet_on(method=3):
            print('# Whoa, your net is alive!')

            play(AUDIO)