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 re import search
|
||||
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()
|
||||
|
||||
# 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_dic(cValues):
|
||||
"""convert coma separate keypairs into a dic. EX "test=5,house=8,market=2" wil return "{'test': '5', 'casa': '8', 'mercado': '2'}" """
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
build
|
||||
dist
|
||||
*spec
|
|
@ -1,8 +1,4 @@
|
|||
import requests
|
||||
import argparse
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
import requests, signal, argparse, sys, os, json
|
||||
|
||||
### Variables and arg parser ###
|
||||
parser = argparse.ArgumentParser(description='Google chat webhook conector')
|
||||
|
@ -23,6 +19,18 @@ parser.add_argument('--btn_url', help='button url',
|
|||
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
build
|
||||
dist
|
||||
*spec
|
|
@ -1 +1,3 @@
|
|||
venv
|
||||
build
|
||||
dist
|
||||
*spec
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import requests, argparse, sys, os
|
||||
import requests, argparse, sys, os, signal
|
||||
from slack_sdk import WebClient
|
||||
from slack_sdk.errors import SlackApiError
|
||||
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()
|
||||
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
|
||||
|
||||
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["error"] # str like 'invalid_auth', 'channel_not_found'
|
||||
print(f"Got an Slack auth error: {e.response['error']}")
|
||||
exit()
|
||||
sys.exit()
|
||||
|
||||
def send_image(imagepath, channel, client) :
|
||||
"""Send file as slack bot"""
|
||||
|
@ -177,4 +189,4 @@ if args.footer: send_message(args.footer, args.channel, client)
|
|||
try:
|
||||
os.remove(filename)
|
||||
except:
|
||||
exit()
|
||||
sys.exit()
|
|
@ -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 base64 import b64decode
|
||||
|
||||
|
@ -27,7 +27,19 @@ def parse_dic(cValues):
|
|||
print(f"Warning, error parsing keypairs values: {e}")
|
||||
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):
|
||||
"""Check apiconfiguration parameters """
|
||||
if args.api_conf :
|
||||
|
|
Loading…
Reference in New Issue