-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpushover.py
More file actions
31 lines (26 loc) · 1.1 KB
/
pushover.py
File metadata and controls
31 lines (26 loc) · 1.1 KB
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
import http.client, urllib
import time
def make_request_with_retry(retries=3, delay=5):
for attempt in range(retries):
try:
conn = http.client.HTTPSConnection("api.pushover.net:443")
conn.request("POST", "/1/messages.json",
urllib.parse.urlencode({
"token": "ajgks2momeurhgxaq1in4x4k5i1dbm",
"user": "u47xaumfiy9zrbh3yw9ejf5hg5d7pq",
"message": "Wake up!!! ",
"sound": "Alien Alarm",
"priority": 1
}),
{"Content-type": "application/x-www-form-urlencoded"})
response = conn.getresponse()
data = response.read()
# print(data)
conn.close()
break # If successful, exit the loop
except http.client.ResponseNotReady as e:
# print(f"Attempt {attempt + 1} failed: {e}")
time.sleep(delay)
except Exception as e:
# print(f"An error occurred: {e}")
break