-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPing_website.py
35 lines (32 loc) · 1013 Bytes
/
Ping_website.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import time
import pytz
import datetime
EST = pytz.timezone('America/New_York')
def pingWebsite():
# terminateConnections()
print('This job is run every 10 minutes')
timeNow = datetime.datetime.now(EST)
timeNow = timeNow.strftime("%H:%M")
timeNow = datetime.datetime.strptime(timeNow, "%H:%M")
timeStart = datetime.datetime.strptime('1:00AM', "%I:%M%p")
timeEnd = datetime.datetime.strptime('10:00AM', "%I:%M%p")
print(timeNow)
print(timeStart)
print(timeEnd)
if timeNow > timeStart and timeNow < timeEnd:
print('Currently In downtime window')
else:
try:
time.sleep(1)
response = requests.get('https://my-stock-dashboard-app.herokuapp.com/')
time.sleep(1)
print(response)
except:
e = sys.exc_info()[0]
print('error on website ping')
print(e)
print('printed error')
else:
print('Ping worked')
pingWebsite()