Add first tr to implement VQiWrapper

This commit is contained in:
Stephan Porada 2019-11-07 15:51:01 +01:00
parent 8e5e8408bd
commit 9be33ffc5a

View File

@ -3,7 +3,7 @@ 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 login_required from flask_login import login_required
from .CQiClient.CQiClient import CQiClient from .CQiWrapper.CQiWrapper import CQiWrapper
import logging import logging
import time import time
@ -32,10 +32,18 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
time.sleep(5) # wait for IP of container only for dev time.sleep(5) # wait for IP of container only for dev
corpus = Corpus.query.filter_by(id=corpus_id).first() corpus = Corpus.query.filter_by(id=corpus_id).first()
logger.warning('IP adress is: {}'.format(corpus.analysis_container_ip)) logger.warning('IP adress is: {}'.format(corpus.analysis_container_ip))
cqi_client = CQiClient(host=corpus.analysis_container_ip) cqi_session = CQiWrapper(username='opaque', password='opaque',
cqi_client.ctrl_connect('opaque', 'opaque') host=corpus.analysis_container_ip, port=4877)
cqi_session.connect()
logger.warning(cqi_session.corpus_list_corpora())
corpus_name = 'CORPUS'
result_subcorpus_name = 'Query-results' # should be set by the user somehow
query = '"and";'
cqi_session.create_attribute_strings(corpus_name)
logger.warning('Log after create_attribute_strings.')
cqi_session.query_subcorpus(corpus_name, result_subcorpus_name, query)
logger.warning('Log after query_subcorpus.')
while session_id in connected_sessions: while session_id in connected_sessions:
logger.warning(cqi_client.ctrl_ping())
logger.warning('Run container, run!') logger.warning('Run container, run!')
socketio.sleep(3) socketio.sleep(3)
corpus.status = 'stop analysis' corpus.status = 'stop analysis'