mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 16:55:05 +02:00
adding signals to avoid tmp trash in fail executions
This commit is contained in:
parent
c385b90da3
commit
c7d19c7036
@ -1 +1,3 @@
|
|||||||
venv
|
build
|
||||||
|
dist
|
||||||
|
*spec
|
@ -1,4 +1,4 @@
|
|||||||
import requests, argparse, sys, os
|
import requests, argparse, sys, os, signal
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from re import search
|
from re import search
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
@ -26,6 +26,18 @@ parser.add_argument('--tmp_dir', help='Temporary path to store graph images', de
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Define a function to handle the SIGINT signal
|
||||||
|
def sigint_handler(signal, frame):
|
||||||
|
print ('\nInterrupted by user')
|
||||||
|
sys.exit(0)
|
||||||
|
signal.signal(signal.SIGINT, sigint_handler)
|
||||||
|
|
||||||
|
# Define a function to handle the SIGTERM signal
|
||||||
|
def sigterm_handler(signum, frame):
|
||||||
|
print("Received SIGTERM signal.")
|
||||||
|
sys.exit(0)
|
||||||
|
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||||
|
|
||||||
### Functions:
|
### Functions:
|
||||||
def parse_dic(cValues):
|
def parse_dic(cValues):
|
||||||
"""convert coma separate keypairs into a dic. EX "test=5,house=8,market=2" wil return "{'test': '5', 'casa': '8', 'mercado': '2'}" """
|
"""convert coma separate keypairs into a dic. EX "test=5,house=8,market=2" wil return "{'test': '5', 'casa': '8', 'mercado': '2'}" """
|
||||||
|
3
pandora_plugins/message_app_connectors/gchat/.gitignore
vendored
Normal file
3
pandora_plugins/message_app_connectors/gchat/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
build
|
||||||
|
dist
|
||||||
|
*spec
|
@ -1,8 +1,4 @@
|
|||||||
import requests
|
import requests, signal, argparse, sys, os, json
|
||||||
import argparse
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import json
|
|
||||||
|
|
||||||
### Variables and arg parser ###
|
### Variables and arg parser ###
|
||||||
parser = argparse.ArgumentParser(description='Google chat webhook conector')
|
parser = argparse.ArgumentParser(description='Google chat webhook conector')
|
||||||
@ -23,6 +19,18 @@ parser.add_argument('--btn_url', help='button url',
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Define a function to handle the SIGINT signal
|
||||||
|
def sigint_handler(signal, frame):
|
||||||
|
print ('\nInterrupted by user')
|
||||||
|
sys.exit(0)
|
||||||
|
signal.signal(signal.SIGINT, sigint_handler)
|
||||||
|
|
||||||
|
# Define a function to handle the SIGTERM signal
|
||||||
|
def sigterm_handler(signum, frame):
|
||||||
|
print("Received SIGTERM signal.")
|
||||||
|
sys.exit(0)
|
||||||
|
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||||
|
|
||||||
# classes
|
# classes
|
||||||
|
|
||||||
|
|
||||||
|
3
pandora_plugins/message_app_connectors/ms-teams/.gitignore
vendored
Normal file
3
pandora_plugins/message_app_connectors/ms-teams/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
build
|
||||||
|
dist
|
||||||
|
*spec
|
@ -1 +1,3 @@
|
|||||||
venv
|
build
|
||||||
|
dist
|
||||||
|
*spec
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import requests, argparse, sys, os
|
import requests, argparse, sys, os, signal
|
||||||
from slack_sdk import WebClient
|
from slack_sdk import WebClient
|
||||||
from slack_sdk.errors import SlackApiError
|
from slack_sdk.errors import SlackApiError
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -26,6 +26,18 @@ parser.add_argument('--tmp_dir', help='Temporary path to store graph images', de
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
filename = None
|
filename = None
|
||||||
|
|
||||||
|
# Define a function to handle the SIGINT signal
|
||||||
|
def sigint_handler(signal, frame):
|
||||||
|
print ('\nInterrupted by user')
|
||||||
|
sys.exit(0)
|
||||||
|
signal.signal(signal.SIGINT, sigint_handler)
|
||||||
|
|
||||||
|
# Define a function to handle the SIGTERM signal
|
||||||
|
def sigterm_handler(signum, frame):
|
||||||
|
print("Received SIGTERM signal.")
|
||||||
|
sys.exit(0)
|
||||||
|
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||||
|
|
||||||
#Functions
|
#Functions
|
||||||
|
|
||||||
def parse_dic(cValues):
|
def parse_dic(cValues):
|
||||||
@ -126,7 +138,7 @@ def send_message(message, channel, client, feddback=None):
|
|||||||
assert e.response["ok"] is False
|
assert e.response["ok"] is False
|
||||||
assert e.response["error"] # str like 'invalid_auth', 'channel_not_found'
|
assert e.response["error"] # str like 'invalid_auth', 'channel_not_found'
|
||||||
print(f"Got an Slack auth error: {e.response['error']}")
|
print(f"Got an Slack auth error: {e.response['error']}")
|
||||||
exit()
|
sys.exit()
|
||||||
|
|
||||||
def send_image(imagepath, channel, client) :
|
def send_image(imagepath, channel, client) :
|
||||||
"""Send file as slack bot"""
|
"""Send file as slack bot"""
|
||||||
@ -177,4 +189,4 @@ if args.footer: send_message(args.footer, args.channel, client)
|
|||||||
try:
|
try:
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
except:
|
except:
|
||||||
exit()
|
sys.exit()
|
3
pandora_plugins/message_app_connectors/telegram-bot-cli/.gitignore
vendored
Normal file
3
pandora_plugins/message_app_connectors/telegram-bot-cli/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
build
|
||||||
|
dist
|
||||||
|
*spec
|
@ -1,4 +1,4 @@
|
|||||||
import requests, argparse, json, sys, os
|
import requests, argparse, json, sys, os, signal
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from base64 import b64decode
|
from base64 import b64decode
|
||||||
|
|
||||||
@ -27,7 +27,19 @@ def parse_dic(cValues):
|
|||||||
print(f"Warning, error parsing keypairs values: {e}")
|
print(f"Warning, error parsing keypairs values: {e}")
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
# Define a function to handle the SIGINT signal
|
||||||
|
def sigint_handler(signal, frame):
|
||||||
|
print ('\nInterrupted by user')
|
||||||
|
sys.exit(0)
|
||||||
|
signal.signal(signal.SIGINT, sigint_handler)
|
||||||
|
|
||||||
|
# Define a function to handle the SIGTERM signal
|
||||||
|
def sigterm_handler(signum, frame):
|
||||||
|
print("Received SIGTERM signal.")
|
||||||
|
sys.exit(0)
|
||||||
|
signal.signal(signal.SIGTERM, sigterm_handler)
|
||||||
|
|
||||||
|
#Functions
|
||||||
def parse_api_conf(cConf):
|
def parse_api_conf(cConf):
|
||||||
"""Check apiconfiguration parameters """
|
"""Check apiconfiguration parameters """
|
||||||
if args.api_conf :
|
if args.api_conf :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user