|
70 | 70 |
|
71 | 71 | class PluginInstanceManager(object):
|
72 | 72 |
|
73 |
| - __NONASCII = re.compile(r'[^\x00-\x7F]') |
74 |
| - |
75 | 73 | def __init__(self, plugin_instance):
|
76 | 74 |
|
77 | 75 | self.c_plugin_inst = plugin_instance
|
@@ -672,8 +670,8 @@ def _register_output_files(self, filenames):
|
672 | 670 | total_size += plg_inst_file.fname.size
|
673 | 671 | self.c_plugin_inst.size += total_size
|
674 | 672 |
|
675 |
| - @classmethod |
676 |
| - def get_job_status_summary(cls, d_response=None): |
| 673 | + @staticmethod |
| 674 | + def get_job_status_summary(d_response=None): |
677 | 675 | """
|
678 | 676 | Get a job status summary JSON string from pfcon response.
|
679 | 677 | """
|
@@ -705,16 +703,8 @@ def get_job_status_summary(cls, d_response=None):
|
705 | 703 | d_jobStatusSummary['compute']['return']['job_status'] = d_c['status']
|
706 | 704 | logs = d_jobStatusSummary['compute']['return']['job_logs'] = d_c['logs']
|
707 | 705 |
|
708 |
| - if len(logs) > 3000: |
709 |
| - # Workaround which fixes https://github.com/FNNDSC/ChRIS_ultron_backEnd/issues/364 |
710 |
| - # Better solution discussed in https://github.com/FNNDSC/ChRIS_ultron_backEnd/issues/374 |
711 |
| - # |
712 |
| - # JSON serialization causes string to be longer than you might expect |
713 |
| - # because of escape sequences, e.g. json.dumps('\n') -> '"\\n"' |
714 |
| - |
715 |
| - # replace non-ASCII characters, such as emojis and Chinese characters |
716 |
| - logs_ascii = cls.__NONASCII.sub('?', logs) |
717 |
| - |
718 |
| - # truncate logs, assuming worst case where every character needs to be escaped |
719 |
| - d_jobStatusSummary['compute']['return']['job_logs'] = logs_ascii[-1800:] |
720 |
| - return json.dumps(d_jobStatusSummary) |
| 706 | + # truncate logs, assuming worst case where every character needs to be escaped |
| 707 | + if len(logs) > 1800: |
| 708 | + d_jobStatusSummary['compute']['return']['job_logs'] = logs[-1800:] |
| 709 | + # PostgreSQL allows UTF-8, supports emojis, chinese, etc. |
| 710 | + return json.dumps(d_jobStatusSummary, ensure_ascii=False) |
0 commit comments