Closed KevinGlassDDL closed 1 month ago
Setting this environment variable works short term.
set PYTHONIOENCODING=UTF-8
The next commander release will fix this issue.
Commander release 16.10.6 fixed this stdout output redirect issue. The output uses utf-8 characters now.
My Vault
├── Folder 1 [Shared]
└── Folder 2
Hello!
I'm in the process of trying to setup a python automation that call keeper-commander.exe and attempts to save the output to a file. However, I'm running into and annoying unicode handling limitation with Windows. This is on the most recent Keeper Commander, tested on Windows 11 and Server 2016.
As an example, if I call
keeper tree
i get this in the console, which is expected:If I call
keeper tree >text.txt
we get this error message.An unexpected error occurred: 'charmap' codec can't encode characters in position 11-13: character maps to <undefined>.
If we copy and paste the output to a text file and open it in a hex editor we can see it's perfectly valid UTF-8 box drawing characters but not correct Ansi.![image](https://github.com/Keeper-Security/Commander/assets/112580772/f5292996-91d8-4445-b344-b0918bb969ae)
I believe this commit that added color support may be the cause but it could have been an earlier change. https://github.com/Keeper-Security/Commander/blame/7c60fc32b0578dde83c36cd4419de240330b0b99/keepercommander/commands/folder.py#L24
In older versions, release 16.8.10 is what I'm using, the
tree
command output like this:Ideally I would like some kind of setting or flag to tell Commander to use the old behavior, or detect when output is being piped, or called from another script. I had hoped --batch-mode would hide non-ascii characters it doesn't change the
tree
behavior. It's also possible a change to charmap might be able to resolve the issue but based on my quick look of the code base and limited understanding of Python, it doesn't seem easy.Thank you!