Returns reported error message from page if it founds one >>> getText(extractErrorMessage(u' Test \\n Warning : oci_parse() [function.oci-parse]: ORA-01756: quoted string not properly terminated Only a test page ') ) 'oci_parse() [function.oci-pa
(page)
| 2856 | return threadData.lastHTTPError[1] if threadData.lastHTTPError else None |
| 2857 | |
| 2858 | def extractErrorMessage(page): |
| 2859 | """ |
| 2860 | Returns reported error message from page if it founds one |
| 2861 | |
| 2862 | >>> getText(extractErrorMessage(u'<html><title>Test</title>\\n<b>Warning</b>: oci_parse() [function.oci-parse]: ORA-01756: quoted string not properly terminated<br><p>Only a test page</p></html>') ) |
| 2863 | 'oci_parse() [function.oci-parse]: ORA-01756: quoted string not properly terminated' |
| 2864 | >>> extractErrorMessage('Warning: This is only a dummy foobar test') is None |
| 2865 | True |
| 2866 | """ |
| 2867 | |
| 2868 | retVal = None |
| 2869 | |
| 2870 | if isinstance(page, six.string_types): |
| 2871 | if wasLastResponseDBMSError(): |
| 2872 | page = re.sub(r"<[^>]+>", "", page) |
| 2873 | |
| 2874 | for regex in ERROR_PARSING_REGEXES: |
| 2875 | match = re.search(regex, page, re.IGNORECASE) |
| 2876 | |
| 2877 | if match: |
| 2878 | candidate = htmlUnescape(match.group("result")).replace("<br>", "\n").strip() |
| 2879 | if candidate and (1.0 * len(re.findall(r"[^A-Za-z,. ]", candidate)) / len(candidate) > MIN_ERROR_PARSING_NON_WRITING_RATIO): |
| 2880 | retVal = candidate |
| 2881 | break |
| 2882 | |
| 2883 | if not retVal and wasLastResponseDBMSError(): |
| 2884 | match = re.search(r"[^\n]*SQL[^\n:]*:[^\n]*", page, re.IGNORECASE) |
| 2885 | |
| 2886 | if match: |
| 2887 | retVal = match.group(0) |
| 2888 | |
| 2889 | return retVal |
| 2890 | |
| 2891 | def findLocalPort(ports): |
| 2892 | """ |
no test coverage detected
searching dependent graphs…