mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 04:12:45 +00:00 
			
		
		
		
	Hups
This commit is contained in:
		@@ -7,7 +7,15 @@ from .CQiWrapper.CQiWrapper import CQiWrapper
 | 
				
			|||||||
import logging
 | 
					import logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					'''
 | 
				
			||||||
 | 
					' A dictionary containing lists of with corpus ids associated Socket.IO session
 | 
				
			||||||
 | 
					' ids (sid). {<corpus_id>: [<sid>, ...], ...}
 | 
				
			||||||
 | 
					'''
 | 
				
			||||||
analysis_sessions = {}
 | 
					analysis_sessions = {}
 | 
				
			||||||
 | 
					'''
 | 
				
			||||||
 | 
					' A dictionary containing Socket.IO session id - CQi client pairs.
 | 
				
			||||||
 | 
					' {<sid>: CQi client, ...}
 | 
				
			||||||
 | 
					'''
 | 
				
			||||||
analysis_clients = {}
 | 
					analysis_clients = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,7 +34,13 @@ def init_corpus_analysis(corpus_id):
 | 
				
			|||||||
def recv_query(message):
 | 
					def recv_query(message):
 | 
				
			||||||
    logger = logging.getLogger(__name__)
 | 
					    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'
 | 
				
			||||||
 | 
					    result_subcorpus_name = 'Query-results'  # should be set by the user somehow
 | 
				
			||||||
 | 
					    query = message['query']
 | 
				
			||||||
 | 
					    analysis_client.create_attribute_strings(corpus_name)
 | 
				
			||||||
 | 
					    analysis_client.query_subcorpus(corpus_name, result_subcorpus_name, query)
 | 
				
			||||||
 | 
					    analysis_client.show_results(corpus_name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def observe_corpus_analysis_connection(app, corpus_id, session_id):
 | 
					def observe_corpus_analysis_connection(app, corpus_id, session_id):
 | 
				
			||||||
@@ -40,18 +54,16 @@ def observe_corpus_analysis_connection(app, corpus_id, session_id):
 | 
				
			|||||||
                                     password='opaque', port=4877,
 | 
					                                     password='opaque', port=4877,
 | 
				
			||||||
                                     username='opaque')
 | 
					                                     username='opaque')
 | 
				
			||||||
        analysis_client.connect()
 | 
					        analysis_client.connect()
 | 
				
			||||||
        analysis_clients['session_id'] = analysis_client
 | 
					        analysis_clients[session_id] = analysis_client
 | 
				
			||||||
        corpus_name = 'CORPUS'
 | 
					 | 
				
			||||||
        result_subcorpus_name = 'Query-results'  # should be set by the user somehow
 | 
					 | 
				
			||||||
        query = '"and";'
 | 
					 | 
				
			||||||
        analysis_client.create_attribute_strings(corpus_name)
 | 
					 | 
				
			||||||
        logger.warning('Log after create_attribute_strings.')
 | 
					 | 
				
			||||||
        analysis_client.query_subcorpus(corpus_name, result_subcorpus_name, query)
 | 
					 | 
				
			||||||
        logger.warning('Log after query_subcorpus.')
 | 
					 | 
				
			||||||
        analysis_client.show_results(corpus_name)
 | 
					 | 
				
			||||||
        while session_id in connected_sessions:
 | 
					        while session_id in connected_sessions:
 | 
				
			||||||
            logger.warning(analysis_client.ctrl_ping())
 | 
					            try:
 | 
				
			||||||
 | 
					                analysis_client.ctrl_ping()
 | 
				
			||||||
 | 
					            except Exception as err:
 | 
				
			||||||
 | 
					                logger.warning('[Exception]: {}'.format(err))
 | 
				
			||||||
 | 
					                break
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
                socketio.sleep(3)
 | 
					                socketio.sleep(3)
 | 
				
			||||||
 | 
					        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)
 | 
				
			||||||
        if not analysis_sessions[str(corpus_id)]:
 | 
					        if not analysis_sessions[str(corpus_id)]:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user