chg: [app] Better error catching and logging
This commit is contained in:
parent
b8b6e8c44a
commit
4a0fe13e1a
4 changed files with 11 additions and 5 deletions
|
@ -298,6 +298,7 @@ def check_inject(user_id: int, inject: dict, data: dict, context: dict) -> bool:
|
||||||
for inject_evaluation in inject['inject_evaluation']:
|
for inject_evaluation in inject['inject_evaluation']:
|
||||||
success = inject_checker_router(user_id, inject_evaluation, data, context)
|
success = inject_checker_router(user_id, inject_evaluation, data, context)
|
||||||
if not success:
|
if not success:
|
||||||
|
logger.info(f"Task not completed: {inject['uuid']}")
|
||||||
return False
|
return False
|
||||||
mark_task_completed(user_id, inject['exercise_uuid'], inject['uuid'])
|
mark_task_completed(user_id, inject['exercise_uuid'], inject['uuid'])
|
||||||
logger.info(f"Task success: {inject['uuid']}")
|
logger.info(f"Task success: {inject['uuid']}")
|
||||||
|
@ -419,7 +420,7 @@ def fetch_data_for_query_comparison(user_id: int, inject_evaluation: dict, perfo
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@debounce_check_active_tasks(debounce_seconds=5)
|
@debounce_check_active_tasks(debounce_seconds=2)
|
||||||
def check_active_tasks(user_id: int, data: dict, context: dict) -> bool:
|
def check_active_tasks(user_id: int, data: dict, context: dict) -> bool:
|
||||||
succeeded_once = False
|
succeeded_once = False
|
||||||
available_tasks = get_available_tasks_for_user(user_id)
|
available_tasks = get_available_tasks_for_user(user_id)
|
||||||
|
|
|
@ -31,7 +31,10 @@ def get(url, data={}, api_key=misp_apikey):
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
logger.info('Could not perform request on MISP. %s', e)
|
logger.info('Could not perform request on MISP. %s', e)
|
||||||
return None
|
return None
|
||||||
|
try:
|
||||||
return response.json() if response.headers['content-type'].startswith('application/json') else response.text
|
return response.json() if response.headers['content-type'].startswith('application/json') else response.text
|
||||||
|
except requests.exceptions.JSONDecodeError:
|
||||||
|
return response.text
|
||||||
|
|
||||||
|
|
||||||
def post(url, data={}, api_key=misp_apikey):
|
def post(url, data={}, api_key=misp_apikey):
|
||||||
|
@ -47,7 +50,10 @@ def post(url, data={}, api_key=misp_apikey):
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
logger.info('Could not perform request on MISP. %s', e)
|
logger.info('Could not perform request on MISP. %s', e)
|
||||||
return None
|
return None
|
||||||
|
try:
|
||||||
return response.json() if response.headers['content-type'].startswith('application/json') else response.text
|
return response.json() if response.headers['content-type'].startswith('application/json') else response.text
|
||||||
|
except requests.exceptions.JSONDecodeError:
|
||||||
|
return response.text
|
||||||
|
|
||||||
|
|
||||||
def getEvent(event_id: int) -> Union[None, dict]:
|
def getEvent(event_id: int) -> Union[None, dict]:
|
||||||
|
|
|
@ -7,7 +7,6 @@ import time
|
||||||
import zmq
|
import zmq
|
||||||
import socketio
|
import socketio
|
||||||
import eventlet
|
import eventlet
|
||||||
from pprint import pprint
|
|
||||||
from eventlet.green import zmq as gzmq
|
from eventlet.green import zmq as gzmq
|
||||||
|
|
||||||
import exercise as exercise_model
|
import exercise as exercise_model
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { io } from "socket.io-client";
|
||||||
import debounce from 'lodash.debounce'
|
import debounce from 'lodash.debounce'
|
||||||
|
|
||||||
// "undefined" means the URL will be computed from the `window.location` object
|
// "undefined" means the URL will be computed from the `window.location` object
|
||||||
const URL = process.env.NODE_ENV === "production" ? undefined : "http://localhost:3000";
|
const URL = process.env.NODE_ENV === "production" ? undefined : "http://localhost:4000";
|
||||||
const MAX_LIVE_LOG = 30
|
const MAX_LIVE_LOG = 30
|
||||||
|
|
||||||
const initial_state = {
|
const initial_state = {
|
||||||
|
|
Loading…
Reference in a new issue