-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UTF-8 support, configuration of conflict resolution and configuration of scm command #26
Conversation
Thanks for the input. 👍 I'll have a look on it (probably during the next week) EDIT: Perhaps @ohumbel can have a look intoit, if he have some spare time 😸 |
I had a rough look on it. Looks good, thank you! And is it possible that you add a small test for the encoding? Like a file which wasnt readable before. |
I definitely prefer: f = open("myfile.txt", "r", encoding="utf-8")
|
Yes, you're right. I have changed it to use python 3 style, added a test and fixed a typo. |
Thanks, I merged them into my development branch |
I tested the code today and on my windows machine I get following exception:
The file itself has utf8 encoding according to notepad++. Any idea? Is that the chcp 65001 you were mentioning? EDIT: I think I had a look on the wrong file. The other file has the encoding ANSI for some reason... |
Hmm. Have you tried chcp 65001? Remember to run chcp without arguments to see the current codepage before switching. |
I havent tried chcp 65001. chcp in console says 850... So do I need to switch something? |
Yeah, you need to do a chcp 65001. Then try to migrate. After this you can switch back: chcp 850. But it seems like utf-8 needs to be configurable as well. |
Sadly doesnt work. The file of the compare gets created always in encoding ANSI, even if I switch to chcp 65001 |
Strange, it works perfectly for me. When I get some time I will have a look. Do you propose that the utf-8 encoding be made an option? |
I dont know... I preferr to find a solution that the file will be written in a proper encoding... |
Yep, so do I, but the output from scm is piped to a file, right? |
Yes, thats correct EDIT:
|
I wrote a simple test which proceeds a file created by scm. It fails when encoding is specified with open... When not specified, everything works. The file isnt in utf8... def testSampleOutput_ShouldbeUTF_ButIsnt(self):
sample_file_path = self.get_Sample_File_Path("SampleFileShouldbeUTF8.txt")
shell.execute("chcp 65001")
#shell.execute("lscm --show-alias n --show-uuid y list components -v -r REPOURL",
# sample_file_path)
with open(sample_file_path, 'r') as file:
for line in file:
print(line)
with open(sample_file_path, 'r', encoding="utf-8") as file:
for line in file:
print(line) The produced file for testing can be found here: |
I just tried chcp 850 and in this case the Compare_baseline file is ANSI and the StreamComponents file is UTF-8 without BOM and the migration fails with: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x82 in position 31: invalid start byte Then I tried chcp 65001 and in this case both files are UTF-8 without BOM and the migration proceeds without errors. |
As you can see I did the chcp 65001 in the test. The output file was utf8 when it didnt contain any special character. If for some reason (in this case ü) there was a special character in the output, the file was ANSI even if before was switched to chcp 65001. Thanks to a hint of a colleague where the problem lies I was able to find a solution after some time. With that I think even the switch of the codepage isnt required anymore (this is untested so far). Neverthless I think the encoding itself needs to be configurable, because the solution needs an additional manual step. So im going to implement that I guess. Its necessary to create a new property config file called magic.properties in the jazz scm tools folder (in Windows C:\Users\USER\AppData\Local\jazz-scm). There you can set an encoding and the output will be in that encoding. My testcommand produces like that always a file with encoding utf8, since then I didnt get any exceptions anymore. You can read about this property in https://jazz.net/wiki/bin/view/Main/SCMMagicFile |
Ahh, yes. :-) I just checked and on my machine I have a magic.properties here: c:\users.jazz-scm with the contents: encoding: UTF-8; I remember now that I changed that quite some time ago. That explains why it works on my machine. |
Well that explains everything 😆 Im happy, though that we found a solution |
congratulations - good research! |
Adds UTF-8 support. On Windows I also need to do a chcp 65001.