Page 1 of 1

[SOLVED] Accents and PyScripter

Published: November 15, 2019 - 11:11
by marcolefo
Good morning,

We are experiencing a problem with accents.
Indeed, they are not recognized correctly when using PyScripter. There is no problem with the Python console.

In the console:

Code: Select all

Python 2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:22:17) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> var = u"éè"
>>> type(var)
<type 'unicode'>
>>> print var
éè
>>>
In the setup.py file via PyScripter:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

def install():
    var = u"éè"
    print type(var)
    print var
And when uninstalling:

Code: Select all

*** Console de processus distant Réinitialisée *** 
>>> 
Ligne de Commande : install "C:\TEMP\test-accents_18.7.2-5\WAPT\.."
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Installing WAPT files C:\TEMP\test-accents_18.7.2-5
<type 'unicode'>
‚Š

Results :

 === install packages ===
  C:\TEMP\test-accents_18.7.2-5 | test-accents (18.7.2-5)
[Bad joke] It's enough to make you lose your UTF-8 [/Bad joke]

The setup.py file is saved in UTF-8 (No BOM) / UNIX.

Do you see where the problem might be coming from?

Re: Accents and PyScripter

Published: November 15, 2019 - 12:27 PM
by htouvet
Good morning,
It's an old problem... that no longer shocks us, we get used to it ;)

In fact, the output of the print statements is redirected to store the result in the Wapt log database, or to the console.

This redirection is managed in waptutils.py by the LogOutput class.

One solution is to replace (around line 1455)

Code: Select all

    def write(self,txt):
        with self.lock:
            txt = ensure_unicode(txt)
            self.output.append(txt)
            if self.update_status_hook and threading.current_thread() == self.threadid and (time.time()-self.last_update_time>=self.update_buffer_time):
                # wait update_buffer_time before sending data to update_hook to avoid high frequency I/O
                self._send_tail_to_updatehook()

            if self.console:
                try:
                    self.console.write(txt)
                except:
                    self.console.write(repr(txt))

by (self.console.write by self.console.stream.write):

Code: Select all

    def write(self,txt):
        with self.lock:
            txt = ensure_unicode(txt)
            self.output.append(txt)
            if self.update_status_hook and threading.current_thread() == self.threadid and (time.time()-self.last_update_time>=self.update_buffer_time):
                # wait update_buffer_time before sending data to update_hook to avoid high frequency I/O
                self._send_tail_to_updatehook()

            if self.console:
                try:
                    self.console.stream.write(txt)
                except:
                    self.console.write(repr(txt))

Re: Accents and PyScripter

Published: November 15, 2019 - 1:06 PM
by marcolefo
THANKS :)

That solves the problem...

One quick question. If the problem has been known for a long time, why not fix it?

The code I provided was a test. In reality, we want to delete a file if it exists.

So the starting code is rather

Code: Select all

# coding: utf-8
from setuphelpers import *

uninstallkey = []

def install():
    licencemanagerfile = ur'C:\TEMP\test_éè\file.txt'

    if (isfile(licencemanagerfile)):
        remove_file(licencemanagerfile)
It now works perfectly, with the proposed modification.
But it would have to be applied to all customers, wouldn't it?

Re: Accents and PyScripter

Published: November 15, 2019 - 1:16 PM
by htouvet
One quick question. If the problem has been known for a long time, why not fix it?
Because nobody had focused on that, and we found the solution just before replying to you...

The fix will be in the next version of Wapt... obviously.

Re: Accents and PyScripter

Published: November 18, 2019 - 3:20 PM
by marcolefo
Great! Thank you :)

Re: [SOLVED] Accents and PyScripter

Published: November 18, 2019 - 3:40 PM
by htouvet
There is a build that includes this accent fix:

https://wapt.tranquil.it/wapt/nightly/w ... -1c00cefd/

Changelog:

WAPT-1.7.4-6237 (2019-11-18) (not released)
----------------------------

(hash 1c00cefd)

* waptserver: add fix to workaround flask-socketio bug https://github.com/miguelgrinberg/Flask ... ssues/1054 (AttributeError: 'Request' object has no attribute 'sid')

* waptserver: be sure db is closed before trying to open it (for dev mode)

* waptserver: add logs messages when an exception message is sent back to the user.

WAPT-1.7.4-6234 (2019-11-14) (not released)
----------------------------

(hash ad237eee)

* waptserver: upgrade peewee DB python module to 3.11.2. explicit connection handling to DB to track potential limbo connections (which could lead to db pool exhaustion)

* waptwua: Trap exception when pushing WU to Windows cache to allow valid updates to be installed even if some could not be verified properly.


WAPT-1.7.4-6232 (2019-10-31)
----------------------------

(hash2090b0e6d52cecfb04f8fa4c279e7c0a0252d6e2

* wapt-get session-setupp: fix bad print in session_setup. regression introduced in b30b1b1a550a4 (1.7.4.6229)

WAPT-1.7.4-6230 (2019-10-23) (not released)
----------------------------
(hash 391d382f)

* return server git hash version and edition in ping and usage_statistics

* be sure to have server_uuid on windows when during setup

* fix for .git partially included in built package manifest

Re: [SOLVED] Accents and PyScripter

Published: November 27, 2019 - 5:01 PM
by Patrice_minagri
Hello,

if I understand correctly, this involves applying the fix to all computers with the WAPT agent installed? Like replacing the original waptutils.py file with its corrected version (via another package, GPO, etc.)?