fix: [internal] Code style

pull/648/head
Jakub Onderka 2024-01-06 14:20:10 +01:00
parent 479ac05bdf
commit 92d7076243
1 changed files with 13 additions and 13 deletions

View File

@ -90,12 +90,12 @@ def load_helpers(helpersdir):
helpers.append(helpername) helpers.append(helpername)
log.info(f'Helpers loaded {filename}') log.info(f'Helpers loaded {filename}')
else: else:
log.info(f'Helpers failed {filename} due to {selftest}') log.warning(f'Helpers failed {filename} due to {selftest}')
def load_package_helpers(): def load_package_helpers():
if not HAS_PACKAGE_HELPERS: if not HAS_PACKAGE_HELPERS:
log.info('Unable to load MISP helpers from package.') log.error('Unable to load MISP helpers from package.')
sys.exit(1) sys.exit(1)
mhandlers = {} mhandlers = {}
helpers = [] helpers = []
@ -109,7 +109,7 @@ def load_package_helpers():
helpers.append(helper_name) helpers.append(helper_name)
log.info(f'Helper loaded {helper_name}') log.info(f'Helper loaded {helper_name}')
else: else:
log.info(f'Helpers failed {helper_name} due to {selftest}') log.warning(f'Helpers failed {helper_name} due to {selftest}')
return mhandlers, helpers return mhandlers, helpers
@ -142,7 +142,7 @@ def load_modules(mod_dir):
def load_package_modules(): def load_package_modules():
if not HAS_PACKAGE_MODULES: if not HAS_PACKAGE_MODULES:
log.info('Unable to load MISP modules from package.') log.error('Unable to load MISP modules from package.')
sys.exit(1) sys.exit(1)
mhandlers = {} mhandlers = {}
modules = [] modules = []
@ -168,12 +168,12 @@ class ListModules(tornado.web.RequestHandler):
def get(self): def get(self):
ret = [] ret = []
for module in loaded_modules: for module_name in loaded_modules:
ret.append({ ret.append({
'name': module, 'name': module_name,
'type': mhandlers['type:' + module], 'type': mhandlers['type:' + module_name],
'mispattributes': mhandlers[module].introspection(), 'mispattributes': mhandlers[module_name].introspection(),
'meta': mhandlers[module].version() 'meta': mhandlers[module_name].version()
}) })
log.debug('MISP ListModules request') log.debug('MISP ListModules request')
self.write(json.dumps(ret)) self.write(json.dumps(ret))
@ -187,9 +187,9 @@ class QueryModule(tornado.web.RequestHandler):
executor = ThreadPoolExecutor(nb_threads) executor = ThreadPoolExecutor(nb_threads)
@run_on_executor @run_on_executor
def run_request(self, module, json_payload): def run_request(self, module_name, json_payload):
log.debug(f'MISP QueryModule request {json_payload}') log.debug('MISP QueryModule request %s', json_payload)
response = mhandlers[module].handler(q=json_payload) response = mhandlers[module_name].handler(q=json_payload)
return json.dumps(response) return json.dumps(response)
@tornado.gen.coroutine @tornado.gen.coroutine
@ -208,7 +208,7 @@ class QueryModule(tornado.web.RequestHandler):
self.write(json.dumps({'error': 'Timeout.'})) self.write(json.dumps({'error': 'Timeout.'}))
except Exception: except Exception:
self.write(json.dumps({'error': 'Something went wrong, look in the server logs for details'})) self.write(json.dumps({'error': 'Something went wrong, look in the server logs for details'}))
log.exception('Something went wrong:') log.exception('Something went wrong when processing query request')
finally: finally:
self.finish() self.finish()