forked from cruim/screenshot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_log.py
30 lines (26 loc) · 867 Bytes
/
error_log.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
import postgresql
import pyaudio
import wave
import db_query
def error_log(module_name, error_message):
db = postgresql.open(db_query.connection_string())
print('Error:' + error_message)
insert = db.prepare("insert into error_log (module_name, error_message) values($1,$2)")
insert(module_name, str(error_message))
play_alarm_sound()
def play_alarm_sound():
return
chunk = 1024
f = wave.open("C:/OSPanel/domains/screenshot/ALERT.wav", "rb")
p = pyaudio.PyAudio()
stream = p.open(format=p.get_format_from_width(f.getsampwidth()),
channels=f.getnchannels(),
rate=f.getframerate(),
output=True)
data = f.readframes(chunk)
while data:
stream.write(data)
data = f.readframes(chunk)
stream.stop_stream()
stream.close()
p.terminate()