-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
57 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
import base64 | ||
import re | ||
from typing import List | ||
import zlib | ||
|
||
|
||
def extract_mantid_code_threads_from_cpp_traces(compressed_cpp_traces: str) -> List[str]: | ||
def extract_mantid_code_threads_from_cpp_traces(compressed_cpp_traces: str): | ||
""" | ||
Take base64 encoded string of the compressed output from pystack core. | ||
Return a list of trace back threads which include code from the mantid repo. | ||
Return a list of trace back threads which includes code from | ||
the mantid repo. | ||
""" | ||
cpp_traces_from_pystack = zlib.decompress(base64.standard_b64decode(compressed_cpp_traces)).decode("utf-8") | ||
return ["Traceback for " + trace_back for trace_back in re.split(r'\nTraceback for ', cpp_traces_from_pystack)[1:] if | ||
cpp_traces_from_pystack = zlib.decompress( | ||
base64.standard_b64decode(compressed_cpp_traces)).decode("utf-8") | ||
return ["Traceback for " + trace_back for trace_back in | ||
re.split(r'\nTraceback for ', cpp_traces_from_pystack)[1:] if | ||
_search_for_mantid_codein_trace(trace_back)] | ||
|
||
|
||
def _search_for_mantid_codein_trace(trace_back: str) -> bool: | ||
cpp_mantid_code = re.search(r"^\s*\(C\) File \".*/(mantid|mantidqt|mantidqtinterfaces|workbench|scripts|plugins)/.*$", trace_back, re.MULTILINE) is not None | ||
python_mantid_code = re.search(r"^\s*\(Python\) File \".*/(mantid|mantidqt|mantidqtinterfaces|workbench|scripts|plugins)/.*$", trace_back, re.MULTILINE) is not None | ||
return cpp_mantid_code or python_mantid_code | ||
cpp_mantid_code = re.search( | ||
r"^\s*\(C\) File \".*/(mantid|mantidqt|mantidqtinterfaces|workbench|" | ||
r"scripts|plugins)/.*$", | ||
trace_back, | ||
re.MULTILINE) is not None | ||
python_mantid_code = re.search( | ||
r"^\s*\(Python\) File \".*/(mantid|" | ||
r"mantidqt|mantidqtinterfaces|workbench|scripts|plugins)/.*$", | ||
trace_back, | ||
re.MULTILINE) is not None | ||
return cpp_mantid_code or python_mantid_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters