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

Encoding error on Windows #148

Open
orels1 opened this issue Apr 12, 2017 · 0 comments
Open

Encoding error on Windows #148

orels1 opened this issue Apr 12, 2017 · 0 comments

Comments

@orels1
Copy link
Contributor

orels1 commented Apr 12, 2017

Hey! Love your project so far, just got it all up and running.
The thing is, though, when running it the first time I encountered an annoying error.

Full traceback:

Traceback (most recent call last):
  File "C:\Users\orel-\AppData\Local\Programs\Python\Python35\Scripts\statuspage-script.py", line 11, in <module>
    load_entry_point('statuspage==0.8.1', 'console_scripts', 'statuspage')()
  File "c:\users\orel-\appdata\local\programs\python\python35\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\orel-\appdata\local\programs\python\python35\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\users\orel-\appdata\local\programs\python\python35\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\orel-\appdata\local\programs\python\python35\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\orel-\appdata\local\programs\python\python35\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\users\orel-\appdata\local\programs\python\python35\lib\site-packages\statuspage\statuspage.py", line 65, in create
    run_create(name=name, token=token, systems=systems, org=org, private=private)
  File "c:\users\orel-\appdata\local\programs\python\python35\lib\site-packages\statuspage\statuspage.py", line 276, in run_create
    content=f.read(),
  File "c:\users\orel-\appdata\local\programs\python\python35\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 56487: character maps to <undefined>

I googled a bit, and found this topic on stackoverflow

And it helped!
Basically I modified this line to also include encoding="utf-8" and it worked like a charm!

So now this code block looks like this

# add all the template files to the gh-pages branch
for template in tqdm(TEMPLATES, desc="Adding template files"):
    with open(os.path.join(ROOT, "template", template), "r", encoding="utf-8") as f:
        repo.create_file(
            path="/" + template,
            message="initial",
            content=f.read(),
            branch="gh-pages"
        )

Hope that helps!

Encountered on Windows 10 with Anniversary update in both ConEmu and Powershell. I use english locale in the system

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

1 participant