mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
Events, CurrentScan, pluginsState, ENABLE_PLUGINS work
This commit is contained in:
@@ -14,29 +14,38 @@ def check_config():
|
||||
return True
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
def send (msg: noti_struc):
|
||||
def send(msg: noti_struc):
|
||||
html = msg.html
|
||||
text = msg.text
|
||||
|
||||
#Define Apprise compatible payload (https://github.com/caronc/apprise-api#stateless-solution)
|
||||
# Define Apprise compatible payload (https://github.com/caronc/apprise-api#stateless-solution)
|
||||
payload = html
|
||||
|
||||
if conf.APPRISE_PAYLOAD == 'text':
|
||||
payload = text
|
||||
|
||||
_json_payload={
|
||||
"urls": conf.APPRISE_URL,
|
||||
"title": "Pi.Alert Notifications",
|
||||
"format": conf.APPRISE_PAYLOAD,
|
||||
"body": payload
|
||||
_json_payload = {
|
||||
"urls": conf.APPRISE_URL,
|
||||
"title": "Pi.Alert Notifications",
|
||||
"format": conf.APPRISE_PAYLOAD,
|
||||
"body": payload
|
||||
}
|
||||
|
||||
try:
|
||||
# try runnning a subprocess
|
||||
p = subprocess.Popen(["curl","-i","-X", "POST" ,"-H", "Content-Type:application/json" ,"-d", json.dumps(_json_payload), conf.APPRISE_HOST], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
stdout, stderr = p.communicate()
|
||||
# write stdout and stderr into .log files for debugging if needed
|
||||
logResult (stdout, stderr) # TO-DO should be changed to mylog
|
||||
# Construct the curl command with input from the JSON payload
|
||||
curl_command = [
|
||||
"curl", "-i", "-X", "POST", "-H", "Content-Type:application/json",
|
||||
conf.APPRISE_HOST
|
||||
]
|
||||
|
||||
# Run the curl command with the JSON payload as input
|
||||
completed_process = subprocess.run(
|
||||
curl_command, input=json.dumps(_json_payload),
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
|
||||
)
|
||||
|
||||
# Log the stdout and stderr
|
||||
logResult(completed_process.stdout, completed_process.stderr) # TO-DO should be changed to mylog
|
||||
except subprocess.CalledProcessError as e:
|
||||
# An error occured, handle it
|
||||
# An error occurred, handle it
|
||||
mylog('none', [e.output])
|
||||
Reference in New Issue
Block a user