Skip to content
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

[BUG] Seems like output dir tree printing in dcm2bids_scaffold assumes UTF-8 encoding which breaks logging on windows #317

Open
kenanoestreich opened this issue Sep 3, 2024 · 1 comment

Comments

@kenanoestreich
Copy link

The core function of dcm2bids_scaffold seems to still be working fine by inspecting the files and directories.

I ran dcm2bids_scaffold -o ~/bids_dir on git bash on Windows 11, and I received a logging error for each file or directory created; each looked like this, with small changes depending on which file or directory it tried to log.

Not a big issue, but might be solved if you can figure out the unicode encoding of the native system. Not sure how all that works.

Here's the error:

--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\username\miniconda3\envs\dcm2bids\Lib\logging\__init__.py", line 1113, in emit
    stream.write(msg + self.terminator)
  File "C:\Users\username\miniconda3\envs\dcm2bids\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode characters in position 55-57: character maps to <undefined>
Call stack:
  File "C:\Users\username\miniconda3\envs\dcm2bids\Scripts\dcm2bids_scaffold-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\username\miniconda3\envs\dcm2bids\Lib\site-packages\dcm2bids\cli\dcm2bids_scaffold.py", line 110, in main
    TreePrinter(args.output_dir).print_tree()
  File "C:\Users\username\miniconda3\envs\dcm2bids\Lib\site-packages\dcm2bids\utils\utils.py", line 209, in print_tree
    logger.info(item)
Message: '\u251c\u2500\u2500 CHANGES'
@arnaudbore
Copy link
Contributor

Hello @kenanoestreich ,

Thank you for reporting this issue.
Can you give a try with the container ? I would be interested in knowing if you get the exact same error with it.

In the meantime I need to find a laptop with Windows 11 now 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants