newsdev/elex-admin

Can't export race overrides with curly quotes?

Closed this issue · 4 comments

Seems like a curly quote may be preventing a race override export?

uWSGI exceptions catcher for "GET /elections/2016/admin/2016-02-01/csv/race/" (request plugin: "python", modifier1: 0)

Exception: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 4: ordinal not in range(128)

Exception class: UnicodeEncodeError

Exception message: 'ascii' codec can't encode character u'\u2019' in position 4: ordinal not in range(128)

Backtrace:
filename: "/home/ubuntu/.virtualenvs/elex-admin-2016-02-01/local/lib/python2.7/site-packages/flask/app.py" line: 1836 function: "__call__" text/code: "return self.wsgi_app(environ, start_response)" 
filename: "/home/ubuntu/.virtualenvs/elex-admin-2016-02-01/local/lib/python2.7/site-packages/flask/app.py" line: 1820 function: "wsgi_app" text/code: "response = self.make_response(self.handle_exception(e))" 
filename: "/home/ubuntu/.virtualenvs/elex-admin-2016-02-01/local/lib/python2.7/site-packages/flask/app.py" line: 1403 function: "handle_exception" text/code: "reraise(exc_type, exc_value, tb)" 
filename: "/home/ubuntu/.virtualenvs/elex-admin-2016-02-01/local/lib/python2.7/site-packages/flask/app.py" line: 1817 function: "wsgi_app" text/code: "response = self.full_dispatch_request()" 
filename: "/home/ubuntu/.virtualenvs/elex-admin-2016-02-01/local/lib/python2.7/site-packages/flask/app.py" line: 1477 function: "full_dispatch_request" text/code: "rv = self.handle_user_exception(e)" 
filename: "/home/ubuntu/.virtualenvs/elex-admin-2016-02-01/local/lib/python2.7/site-packages/flask/app.py" line: 1381 function: "handle_user_exception" text/code: "reraise(exc_type, exc_value, tb)" 
filename: "/home/ubuntu/.virtualenvs/elex-admin-2016-02-01/local/lib/python2.7/site-packages/flask/app.py" line: 1475 function: "full_dispatch_request" text/code: "rv = self.dispatch_request()" 
filename: "/home/ubuntu/.virtualenvs/elex-admin-2016-02-01/local/lib/python2.7/site-packages/flask/app.py" line: 1461 function: "dispatch_request" text/code: "return self.view_functions[rule.endpoint](**req.view_args)" 
filename: "elex_admin/app.py" line: 79 function: "overrides_csv" text/code: "writer.writerows(objs)" 
filename: "/usr/lib/python2.7/csv.py" line: 158 function: "writerows" text/code: "return self.writer.writerows(rows)" 


REQUEST_METHOD = GET
REQUEST_URI = /elections/2016/admin/2016-02-01/csv/race/
PATH_INFO = /elections/2016/admin/2016-02-01/csv/race/
QUERY_STRING = 
SERVER_PROTOCOL = HTTP/1.0
SCRIPT_NAME = 
SERVER_NAME = ip-10-65-206-236
SERVER_PORT = 8005
REMOTE_ADDR = 127.0.0.1
HTTP_HOST = 127.0.0.1:8005
HTTP_CONNECTION = close
HTTP_ACCEPT = text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_ACCEPT_ENCODING = gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE = en-US,en;q=0.8
HTTP_COOKIE = __gads=ID=9a0a332661dd7d91:T=1428690021:S=ALNI_MYbs4U3nIOEt8TmtY9blRWFxX5DOA; _ga=GA1.2.1822301978.1440685338; _dyid=-7484982536318064009; _cb_ls=1; __utma=117169502.1822301978.1440685338.1455041728.1455052985.3; __utmz=117169502.1455034057.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); optimizelyEndUserId=oeu1453748884372r0.9268277115188539; optimizelySegments=%7B%223007620980%22%3A%22referral%22%2C%223013750536%22%3A%22false%22%2C%223028090192%22%3A%22gc%22%2C%223032570147%22%3A%22none%22%2C%223315571554%22%3A%22direct%22%2C%223321851195%22%3A%22false%22%2C%223334171090%22%3A%22none%22%2C%223336921036%22%3A%22gc%22%2C%223763824064%22%3A%22gc%22%2C%223772273677%22%3A%22direct%22%2C%223774343588%22%3A%22false%22%2C%223778135334%22%3A%22none%22%7D; optimizelyBuckets=%7B%7D; _chartbeat2=DefSi9DzsrLqDD_-cA.1454515181373.1455639469472.10100011000001; WT_FPC=id=01c0bf11-0544-4607-bd90-21b6b6e16b8c:lv=1455639469653:ss=1455639048695; _dycst=dk.m.c.ms.frv2.ltos.; _dy_geo=US.NA.US_NY.US_NY_New%20York; _dy_toffset=0; _dyus_8765260=17933%7C6%7C0%7C3%7C0%7C0.0.1453748884635.1455639469776.1890585.0%7C46%7C8%7C1%7C116%7C3%7C0%7C0%7C0%7C11%7C17%7C39%7C3%7C122%7C143%7C165%7C0%7C0%7C188%7C245%7C0%7C0%7C0%7C0
HTTP_REFERER = http://int-elex-prd-east.newsdev.net/elections/2016/admin/2016-02-01/
HTTP_UPGRADE_INSECURE_REQUESTS = 1
HTTP_USER_AGENT = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36
HTTP_X_FORWARDED_FOR = 170.149.100.10
HTTP_X_FORWARDED_PORT = 80
HTTP_X_FORWARDED_PROTO = http

Ugh, yeah, that's not impossible.

This is all going to be HTML in the end, so can I htmlencode that curly quote @giratikanon ?

Sure.

Nah, I can probably fix this with csvkit and unicode support.