<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div><div><br><br>Barry<div><br></div></div>On 7 Feb 2017, at 22:28, Kyle Altendorf <<a href="mailto:sda@fstab.net">sda@fstab.net</a>> wrote:<br><br></div><blockquote type="cite"><div><span>On 2017-02-07 16:47, Dave Gradwell wrote:</span><br><blockquote type="cite"><span>If my pyqtdeploy’ed app is run from under pyqtdeploy itself (with the</span><br></blockquote><blockquote type="cite"><span>‘run application’ checkbox) then it can send UTF-8 characters to the</span><br></blockquote><blockquote type="cite"><span>Python logging module, which end up in a log file — which is good.  It</span><br></blockquote><blockquote type="cite"><span>also works fine in interpreted/development mode, i.e., unpackaged.</span><br></blockquote><blockquote type="cite"><span>But if I quit pyqtdeploy and immediately just double click the (now</span><br></blockquote><blockquote type="cite"><span>packaged) app then it fails to log UTF-8 with the error message</span><br></blockquote><blockquote type="cite"><span>"UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in</span><br></blockquote><blockquote type="cite"><span>position 66: ordinal not in range(128)”</span><br></blockquote><span></span><br><span>Is this Windows?  Is it a GUI application?  If so, I found that when deployed my sys.stdout and sys.stderr were actually None.  I won't recommend what I have done as _good_ but I will share it in case it is _useful_ at least for exploration.</span><br><span></span><br><span><a href="https://github.com/altendky/st/blob/master/epyq/__main__.py#L11-L24">https://github.com/altendky/st/blob/master/epyq/__main__.py#L11-L24</a></span><br><span><a href="https://github.com/altendky/st/blob/26bfdb5a8409e20e9fc6870f6a9e56ddc516f65b/epyqlib/tee.py">https://github.com/altendky/st/blob/26bfdb5a8409e20e9fc6870f6a9e56ddc516f65b/epyqlib/tee.py</a></span><br><span></span><br><span>Roughly speaking I replace sys.stdout and sys.stderr *shudder* with either my log file or my tee object which sends to both the file and stdout/err.  Nasty, but without it I was flying totally blind except that my application stopped running.  Someday I'll do a proper logging solution.</span><br></div></blockquote><div><br></div><div>What I do for Windows is intercept writes to stdout and stderr and write them the logging system.</div><div><br></div><div>See the the logging code in <a href="https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_logging.py">https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_logging.py</a></div><div><br></div><div>And the setup in <a href="https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_app.py">https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_app.py</a></div><div><br></div><div>The features I needed are:</div><div>* log rotation and max size limits</div><div>* optionally capture stdout and stderr - always on for production</div><div>* optionally output log to stdout - used while debugging</div><div>* output to Qt Widget</div><div><br></div><div><br></div><div><br></div><div><br></div><blockquote type="cite"><div><span></span><br><blockquote type="cite"><span>I have the appropriate encoding hint at the top of my .py files  # -*-</span><br></blockquote><blockquote type="cite"><span>coding: utf-8 -*-</span><br></blockquote><span></span><br><span>My understanding is that that is for Python 2 for parsing the code file itself and would not be relevant here.</span><br><span></span><br><span>Cheers,</span><br><span>-kyle</span><br><span>_______________________________________________</span><br><span>PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a></span><br><span><a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></span></div></blockquote></body></html>