[SOLVED] Accents and PyScripter

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
marcolefo
Messages: 27
Registration: Oct 02, 2018 - 11:13

November 15, 2019 - 11:11

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?
Last edited by marcolefo on Nov 18, 2019 - 3:21 PM, edited 2 times.
WAPT Enterprise Server: 2.6.0.17343 / Server OS: Debian bookworm /
Administration/package creation machine OS: macOS 15
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

November 15, 2019 - 12:27

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))
Tranquil IT
marcolefo
Messages: 27
Registration: Oct 02, 2018 - 11:13

November 15, 2019 - 1:06 PM

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?
WAPT Enterprise Server: 2.6.0.17343 / Server OS: Debian bookworm /
Administration/package creation machine OS: macOS 15
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

November 15, 2019 - 1:16 PM

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.
Tranquil IT
marcolefo
Messages: 27
Registration: Oct 02, 2018 - 11:13

November 18, 2019 - 3:20 PM

Great! Thank you :)
WAPT Enterprise Server: 2.6.0.17343 / Server OS: Debian bookworm /
Administration/package creation machine OS: macOS 15
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

November 18, 2019 - 3:40 PM

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
Tranquil IT
Patrice_minagri
Messages: 57
Registration: Oct 21, 2016 - 4:56 p.m.

November 27, 2019 - 5:01 PM

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.)?
WAPT 1.7.4
Locked