From 9be33ffc5a22daf9e58e6ee7f8b494ea41e917d6 Mon Sep 17 00:00:00 2001 From: Stephan Porada Date: Thu, 7 Nov 2019 15:51:01 +0100 Subject: [PATCH] Add first tr to implement VQiWrapper --- app/corpora/events.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/corpora/events.py b/app/corpora/events.py index 36f9f34d..7dfbc05b 100644 --- a/app/corpora/events.py +++ b/app/corpora/events.py @@ -3,7 +3,7 @@ from app.events import connected_sessions from app.models import Corpus from flask import current_app, request from flask_login import login_required -from .CQiClient.CQiClient import CQiClient +from .CQiWrapper.CQiWrapper import CQiWrapper import logging 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 corpus = Corpus.query.filter_by(id=corpus_id).first() logger.warning('IP adress is: {}'.format(corpus.analysis_container_ip)) - cqi_client = CQiClient(host=corpus.analysis_container_ip) - cqi_client.ctrl_connect('opaque', 'opaque') + cqi_session = CQiWrapper(username='opaque', password='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: - logger.warning(cqi_client.ctrl_ping()) logger.warning('Run container, run!') socketio.sleep(3) corpus.status = 'stop analysis'