Default encoding is ascii cause cert:omni-analyzer generate html report failed

RESOLVED FIXED

Status

RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: oouyang, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
Created attachment 8542467 [details]
cert-omni-analyzer-firefox-os-certification_20141230124336.zip

In some ascii encoding environment, generate html file throw the following exception.

Traceback (most recent call last): 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/fxos_certsuite-2.0.1-py2.7.egg/certsuite/cert.py", line 696, in cli _run(args, logger) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/fxos_certsuite-2.0.1-py2.7.egg/certsuite/cert.py", line 653, in _run make_html_report(args.html_result_file, report) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/fxos_certsuite-2.0.1-py2.7.egg/certsuite/cert.py", line 351, in make_html_report f.write(str(doc)) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 48, in __unicode__ return self.unicode(indent=0) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 69, in unicode HtmlVisitor(l.append, indent, shortempty=False).visit(self) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 126, in visit visitmethod(node) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 158, in Tag self.visit(x) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 126, in visit visitmethod(node) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 158, in Tag self.visit(x) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 126, in visit visitmethod(node) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 141, in list self.visit(elem) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 126, in visit visitmethod(node) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 158, in Tag self.visit(x) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 126, in visit visitmethod(node) 
File "/media/windows/work/B2G/fxos-MCTS-2.0/mcts2.0/local/lib/python2.7/site-packages/py-1.4.20-py2.7.egg/py/_xmlgen.py", line 132, in __object self.write(escape(unicode(obj))) 
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 32: ordinal not in range(128) 


Base on http://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte
add the following code 

        import sys
        reload(sys)
        sys.setdefaultencoding('utf8')

before 
https://github.com/Mozilla-TWQA/fxos-certsuite/blob/master/certsuite/cert.py#L351
(Reporter)

Updated

4 years ago
Summary: Default encoding is ascii may cause cert:omni-analyzer generate html report failed → Default encoding is ascii cause cert:omni-analyzer generate html report failed
Attempted to resolve with https://github.com/mozilla-b2g/fxos-certsuite/commit/21fd90186a5bcbae86e12318f3493685efe0a78b on the v2.0 branch; can you see if it still persists there?
(Reporter)

Comment 2

4 years ago
I still got the following error
Traceback (most recent call last):
  File "/usr/lib/python2.7/pdb.py", line 1314, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib/python2.7/pdb.py", line 1233, in _runscript
    self.run(statement)
  File "/usr/lib/python2.7/bdb.py", line 400, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "v2.1/bin/cert", line 9, in <module>
    load_entry_point('fxos-certsuite==2.1.1', 'console_scripts', 'cert')()
  File "/media/windows/work/B2G/mcts-b2g/v2.1/local/lib/python2.7/site-packages/fxos_certsuite-2.1.1-py2.7.egg/certsuite/cert.py", line 747, in cli 
    _run(args, logger)
  File "/media/windows/work/B2G/mcts-b2g/v2.1/local/lib/python2.7/site-packages/fxos_certsuite-2.1.1-py2.7.egg/certsuite/cert.py", line 704, in _run
    make_html_report(args.html_result_file, report)
  File "/media/windows/work/B2G/mcts-b2g/v2.1/local/lib/python2.7/site-packages/fxos_certsuite-2.1.1-py2.7.egg/certsuite/cert.py", line 357, in make_html_report
    body_els.append(tabelize(report[key]))
  File "/media/windows/work/B2G/mcts-b2g/v2.1/local/lib/python2.7/site-packages/fxos_certsuite-2.1.1-py2.7.egg/certsuite/cert.py", line 344, in tabelize
    return html.pre(value.encode('ascii', 'ignore'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)
Flags: needinfo?(jgriffin)
Thanks for trying again, Oouyang.  I've pushed another fix to the v2.1 branch, could you possibly try again?
Flags: needinfo?(jgriffin)
(Reporter)

Comment 4

4 years ago
The new fix should resolve this problem.
But I got another different error:

 0:36.48 PROCESS_OUTPUT: Thread-11 (pid:15548) "diff: extra operand '/tmp/tmpXKajSF/device'"
 0:36.48 PROCESS_OUTPUT: Thread-11 (pid:15548) "diff: Try 'diff --help' for more information."
 0:36.35 LOG: MainThread ERROR error running diff: 2
(In reply to oo[oouyang] from comment #4)
> The new fix should resolve this problem.
> But I got another different error:
> 
>  0:36.48 PROCESS_OUTPUT: Thread-11 (pid:15548) "diff: extra operand
> '/tmp/tmpXKajSF/device'"
>  0:36.48 PROCESS_OUTPUT: Thread-11 (pid:15548) "diff: Try 'diff --help' for
> more information."
>  0:36.35 LOG: MainThread ERROR error running diff: 2

Fixed with https://github.com/mozilla-b2g/fxos-certsuite/commit/845b25c59b9597d5bc6fedfbe091fc0172a9fe52
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.