Last active
January 17, 2019 04:00
-
-
Save kunimi53chi/11eba69c29d3582356d4336c6fc66c38 to your computer and use it in GitHub Desktop.
Kancolle Cat Notification (Python 3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import winsound | |
import requests | |
import sys | |
import time | |
# access to your server's banner | |
WATCH_URL = 'http://xxx.xxx.xxx.xxx/kcs/resources/image/world/xxx_xxx_xxx_xxx_t.png' | |
def alert(): | |
winsound.PlaySound('hogesound.wav', winsound.SND_FILENAME) | |
def ping(): | |
winsound.PlaySound('hogesound.wav', winsound.SND_FILENAME) | |
def sleep(): | |
time.sleep(45) | |
# If you want to stop, pless ^C on terminal | |
while(True): | |
try: | |
ping() | |
time.sleep(6) | |
r = requests.get(WATCH_URL, timeout=5) | |
r.raise_for_status() | |
sleep() | |
except requests.exceptions.Timeout: | |
print('Response is too slow. Isnt it the Cat?' ) | |
alert() | |
sleep() | |
continue | |
except requests.exceptions.HTTPError: | |
print('HTTP Error occured. Isnt it the Cat?') | |
alert() | |
sleep() | |
continue | |
except Exception as e: | |
print('Unexpected Exception occured.') | |
print('{}: {}'.format(type(e).__name__, str(e))) | |
winsound.PlaySound('hogesound.wav', winsound.SND_FILENAME) | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I sure hope you know what you are doing