jayfk / jayfk/statuspage

Encoding error on Windows

Open
#148 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3.9k
Forks
180
PR merge metrics
No merged PRs in 30d

Description

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:

```bash
Traceback (most recent call last):
File "C:\Users\orel-\AppData\Local\Programs\Python\Python35\Scripts\statuspage-script.py", line 11, in
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
```

I googled a bit, and found [this topic on stackoverflow](https://stackoverflow.com/questions/9233027/unicodedecodeerror-charmap-codec-cant-decode-byte-x-in-position-y-character)

And it helped!
Basically I modified [this line](https://github.com/jayfk/statuspage/blob/master/statuspage/statuspage.py#L269) to also include `encoding="utf-8"` and it worked like a charm!

So now this code block looks like this

```python
# 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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in statuspage/statuspage.py around line 269, where run_create opens the template files during the create command. Reproduce the first-run flow on Windows and verify that template processing completes without the reported UnicodeDecodeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, operating-systems
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.