Issue Number | 4186 |
---|---|
Summary | Error accessing GP Mailers |
Created | 2016-11-10 17:36:39 |
Issue Type | Bug |
Submitted By | Osei-Poku, William (NIH/NCI) [C] |
Assigned To | Kline, Bob (NIH/NCI) [C] |
Status | Closed |
Resolved | 2016-11-15 15:10:44 |
Resolution | Fixed |
Path | /home/bkline/backups/jira/ocecdr/issue.198165 |
We are getting the following error message when accessing GP Mailers on PROD:
Here the link to one of the mailers:
https://gpmailers.cancer.gov/cgi-bin/ShowGPChanges.py?id=784472
"#!/usr/bin/python
#-------------------------------------------------------------------— #
# $Id: ShowGPChanges.py 11829 2013-06-02 22:08:19Z bkline $ # # Display
a diff report between the original information for a # genetics
professional and the information as modified in the # mailer interface
by the GP. #
#-------------------------------------------------------------------—
import cgi, cdrutil, difflib, lxml.etree as etree def show(me): print
"""\ Content-type: text/html; charset: utf-8 %s
""" % me def fix(me): xml = etree.tostring(etree.XML(me),
pretty_print=True) return xml.replace("\r", "").splitlines(1) def
addColor(line, color): return "%s" % (color, line) def main(): fields =
cgi.FieldStorage() mailerId = fields.getvalue('id') cursor =
cdrutil.getConnection('emailers').cursor() cursor.execute("SELECT
original, xml FROM gp_emailer WHERE id = %s", mailerId) original, new =
cursor.fetchone() diffObj = difflib.Differ() before = fix(original)
after = fix(new) diffSeq = diffObj.compare(before, after) lines = []
changes = False for line in diffSeq: line = cgi.escape(line) if not
line.startswith(' '): changes = True if line.startswith('-'):
lines.append(addColor(line, '#FAFAD2')) # Light goldenrod yellow elif
line.startswith('+'): lines.append(addColor(line, '#F0E68C')) # Khaki
elif line.startswith('?'): lines.append(addColor(line, '#87CEFA')) #
Light sky blue else: lines.append(line) if not changes: show("No
changes") else: show("".join(lines)) #show("".join(diffSeq)) if
name == 'main': main() "
Should I close this ticket ?
Yes, I think so.
This has been fixed and tested on Prod.
Elapsed: 0:00:00.001332