Unicode Decode error on final re-zip in pod renderer

Asked by Heather Morrison on 2012-01-30

I'm trying to create a number of reports and I am randomly getting the following error:

<type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0x91 in position 10: ordinal not in range(128)

It appears to be happening at the re-zip stage in the renderer. More specifically, when the folderName variable is being assigned in the finalize method. One execution a report will fail and then the following execution the same data will successfully be written to a report. Any ideas?

Thanks for building this, when it works - it's awesome!!

Thanks,
Heather

Question information

Language:
English Edit question
Status:
Solved
For:
Appy Edit question
Assignee:
No assignee Edit question
Solved by:
Heather Morrison
Solved:
2012-05-07
Last query:
2012-05-07
Last reply:
2012-04-25
Launchpad Janitor (janitor) said : #1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Hello,
Sorry for the late answer. Could you send me a traceback ??
Thanks,
Gaetan

Maybe a bug...

Heather Morrison (morrison-h) said : #4

Traceback (most recent call last):
  File "E:\GISData\Projects\METreeGrowthTax\Scripts\WriteReport.py", line 76, in generateReport
    self.completeSchedule()
  File "E:\GISData\Projects\METreeGrowthTax\Scripts\WriteReport.py", line 563, in completeSchedule
    self.renderer.run()
  File "E:\GISData\Projects\METreeGrowthTax\Scripts\appy\pod\renderer.py", line 387, in run
    self.finalize()
  File "E:\GISData\Projects\METreeGrowthTax\Scripts\appy\pod\renderer.py", line 510, in finalize
    resultOdt.write(os.path.join(dir, f), os.path.join(folderName, f))
  File "C:\Python25\Lib\zipfile.py", line 568, in write
    self.fp.write(zinfo.FileHeader())
  File "C:\Python25\Lib\zipfile.py", line 260, in FileHeader
    return header + self.filename + extra
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9b in position 10: ordinal not in range(128)

This error will repeat many times in my try - except and then randomly will work again. Sometimes I don't get an error at all and it works perfectly. Help!

Launchpad Janitor (janitor) said : #5

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Heather Morrison (morrison-h) said : #6

I am now getting this error every time I run my application and I can't generate any reports... help!

Launchpad Janitor (janitor) said : #7

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Heather Morrison (morrison-h) said : #8

Has anyone had a chance to look into this? I am still having trouble...

Hello,
Coudl you give me more information about the bug:
- File "C:\Python25\Lib\zipfile.py", line 260, in FileHeader
  Could you try to print self.filename ?
- File "E:\GISData\Projects\METreeGrowthTax\Scripts\appy\pod\renderer.py", line 510, in finalize
    resultOdt.write(os.path.join(dir, f), os.path.join(folderName, f))
  Could you give me the values of variables "dir", "folderName", "f"...
  There is probably some name that contains special chars. What is the name of the result file you ask POD to produce? You may try to apply on this name function appy.shared.utils.normalizeString, that removes any "special" char from a filename, to avoid encoding problems...
Hope this wilk help!
Gaetan

Heather Morrison (morrison-h) said : #10

Hello Gaetan:

This is the trace you asked for (printed just before resultOdt.write(os.path.join(dir, f), os.path.join(folderName, f)) in the finalize function ../pod/renderer.py) :

self.filename: content.xml

dir: E:\GISData\Projects\METreeGrowthTax\Results\APRIL25\TreeTaxApplication_BigTwentyTwpA.odt.1335439722.944000\unzip
folderName:
f: content.xml

Should folderName be coming up blank?

The resulting files are being named "TreeTaxApplication_" then the name of the desired township and label letter. I have a function that removes all the spaces and I have checked that there are no special characters in the list.

Heather Morrison (morrison-h) said : #11

Gaetan, have you had a chance to look at this? Thanks.

Heather Morrison (morrison-h) said : #12

Hi all - I finally solved it!!

Basically I just made sure that everything that is passed in to appy was type cast as a string and it worked! I'm still not sure why I was having intermittent success before... but it works great now!

Thank you Gaetan for your help - it kept me from giving up!