[PyQt] Logging UTF-8 when pyqtdeployed
Barry
barry at barrys-emacs.org
Sat Feb 11 16:00:46 GMT 2017
Barry
> On 7 Feb 2017, at 22:28, Kyle Altendorf <sda at fstab.net> wrote:
>
>> On 2017-02-07 16:47, Dave Gradwell wrote:
>> If my pyqtdeploy’ed app is run from under pyqtdeploy itself (with the
>> ‘run application’ checkbox) then it can send UTF-8 characters to the
>> Python logging module, which end up in a log file — which is good. It
>> also works fine in interpreted/development mode, i.e., unpackaged.
>> But if I quit pyqtdeploy and immediately just double click the (now
>> packaged) app then it fails to log UTF-8 with the error message
>> "UnicodeEncodeError: 'ascii' codec can't encode character '\xfc' in
>> position 66: ordinal not in range(128)”
>
> 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.
>
> https://github.com/altendky/st/blob/master/epyq/__main__.py#L11-L24
> https://github.com/altendky/st/blob/26bfdb5a8409e20e9fc6870f6a9e56ddc516f65b/epyqlib/tee.py
>
> 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.
What I do for Windows is intercept writes to stdout and stderr and write them the logging system.
See the the logging code in https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_logging.py
And the setup in https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_app.py
The features I needed are:
* log rotation and max size limits
* optionally capture stdout and stderr - always on for production
* optionally output log to stdout - used while debugging
* output to Qt Widget
>
>> I have the appropriate encoding hint at the top of my .py files # -*-
>> coding: utf-8 -*-
>
> My understanding is that that is for Python 2 for parsing the code file itself and would not be relevant here.
>
> Cheers,
> -kyle
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170211/05ab298c/attachment.html>
More information about the PyQt
mailing list