Compare commits

..

3 Commits

Author SHA1 Message Date
Patrick Jentsch
41d8dbad5d simplify decompression and decoding 2023-07-12 11:25:58 +02:00
Patrick Jentsch
203faa4257 Remove debug messages and move data inflation into api fn 2023-07-12 11:11:15 +02:00
Patrick Jentsch
960f36c740 Fix BrokenPipeError handling in cqi_over_socketio 2023-07-12 10:54:52 +02:00
3 changed files with 6 additions and 15 deletions

View File

@ -86,11 +86,8 @@ def cqi_over_sio(fn_name: str, fn_args: Dict = {}):
cqi_client_lock.acquire()
try:
fn_return_value = fn(**fn_args)
except BrokenPipeError:
fn_return_value = {
'code': 500,
'msg': 'Internal Server Error'
}
except BrokenPipeError as e:
return {'code': 500, 'msg': 'Internal Server Error'}
except CQiException as e:
return {
'code': 502,

View File

@ -630,7 +630,9 @@ cqi.api.APIClient = class APIClient {
async ext_corpus_static_data(corpus) {
const fn_name = 'ext_corpus_static_data';
const fn_args = {corpus: corpus};
return await this.#request(fn_name, fn_args);
let compressedEncodedData = await this.#request(fn_name, fn_args);
let data = pako.inflate(compressedEncodedData, {to: 'string'});
return JSON.parse(data);
}
/**

View File

@ -138,15 +138,7 @@ cqi.models.corpora.CorpusCollection = class CorpusCollection extends cqi.models.
/************************************************************************
* Custom additions for nopaque *
************************************************************************/
// returnValue.static_data = await this.client.api.ext_corpus_static_data(corpusName);
let tmp = await this.client.api.ext_corpus_static_data(corpusName);
console.log(tmp);
let inflated = pako.inflate(tmp);
console.log(inflated);
let decoder = new TextDecoder('utf-8');
console.log(decoder);
let decoded = decoder.decode(inflated);
returnValue.static_data = JSON.parse(decoded);
returnValue.static_data = await this.client.api.ext_corpus_static_data(corpusName);
return returnValue;
}