mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 02:44:18 +00:00
Implement logger in another way.
This commit is contained in:
parent
6459c9f064
commit
2bebd0256c
@ -4,9 +4,11 @@ from flask_login import LoginManager
|
|||||||
from flask_mail import Mail
|
from flask_mail import Mail
|
||||||
from flask_socketio import SocketIO
|
from flask_socketio import SocketIO
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
|
import logging
|
||||||
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
login_manager.login_view = 'auth.login'
|
login_manager.login_view = 'auth.login'
|
||||||
mail = Mail()
|
mail = Mail()
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
from app import db, socketio
|
from app import db, logger, socketio
|
||||||
from app.events import connected_sessions
|
from app.events import connected_sessions
|
||||||
from app.models import Corpus
|
from app.models import Corpus
|
||||||
from flask import current_app, request
|
from flask import current_app, request
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from .CQiWrapper.CQiWrapper import CQiWrapper
|
from .CQiWrapper.CQiWrapper import CQiWrapper
|
||||||
import logging
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
@ -40,24 +38,22 @@ def init_corpus_analysis(corpus_id):
|
|||||||
@socketio.on('query_event')
|
@socketio.on('query_event')
|
||||||
@login_required
|
@login_required
|
||||||
def recv_query(message):
|
def recv_query(message):
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
logger.warning(message)
|
logger.warning(message)
|
||||||
analysis_client = analysis_clients[request.sid]
|
analysis_client = analysis_clients[request.sid]
|
||||||
corpus_name = 'CORPUS'
|
corpus_name = 'CORPUS'
|
||||||
result_subcorpus_name = 'Query-results'
|
result_subcorpus_name = 'Query-results' # should be set by the user somehow
|
||||||
query = message['query']
|
query = message['query']
|
||||||
analysis_client.set_corpus_name(corpus_name)
|
analysis_client.set_corpus_name(corpus_name)
|
||||||
analysis_client.create_attribute_strings()
|
analysis_client.create_attribute_strings()
|
||||||
analysis_client.query_subcorpus(result_subcorpus_name, query)
|
analysis_client.query_subcorpus(result_subcorpus_name, query)
|
||||||
results = analysis_client.show_results()
|
logger.warning('Vorher')
|
||||||
|
#results = analysis_client.show_results()
|
||||||
|
results = analysis_client.get_cpos_info([1995, 2000], analysis_client)
|
||||||
|
logger.warning('Nacher')
|
||||||
logger.warning('Query results: {}'.format(str(results)))
|
logger.warning('Query results: {}'.format(str(results)))
|
||||||
json_results = json.dumps(results)
|
|
||||||
logger.warning('JSON results are {}'.format(json_results))
|
|
||||||
socketio.emit('query_results', json_results)
|
|
||||||
|
|
||||||
|
|
||||||
def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
corpus = Corpus.query.filter_by(id=corpus_id).first()
|
||||||
while corpus.status != 'analysing':
|
while corpus.status != 'analysing':
|
||||||
@ -70,6 +66,7 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
|||||||
analysis_clients[session_id] = analysis_client
|
analysis_clients[session_id] = analysis_client
|
||||||
socketio.emit('init_corpus_analysis', 'Ready', room=session_id)
|
socketio.emit('init_corpus_analysis', 'Ready', room=session_id)
|
||||||
while session_id in connected_sessions:
|
while session_id in connected_sessions:
|
||||||
|
'''
|
||||||
try:
|
try:
|
||||||
analysis_client.ctrl_ping()
|
analysis_client.ctrl_ping()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
@ -77,6 +74,8 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
socketio.sleep(3)
|
socketio.sleep(3)
|
||||||
|
'''
|
||||||
|
socketio.sleep(3)
|
||||||
analysis_client.disconnect()
|
analysis_client.disconnect()
|
||||||
analysis_clients.pop(session_id, None)
|
analysis_clients.pop(session_id, None)
|
||||||
analysis_sessions[str(corpus_id)].remove(session_id)
|
analysis_sessions[str(corpus_id)].remove(session_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user