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

Fix server icon saving example #591

Merged
merged 2 commits into from
Jul 17, 2023
Merged

Fix server icon saving example #591

merged 2 commits into from
Jul 17, 2023

Conversation

ItsDrike
Copy link
Member

@ItsDrike ItsDrike commented Jul 17, 2023

The original example we had in FAQ doesn't work for multiple reasons:

  1. base64.decodebytes function expects bytes as the input arg, however status.icon is a string, we should be using base64.b64decode instead.
  2. The base64 data is prefixed with "data:image/png;base64,", which isn't valid base64 data, and should not be a part of the saved PNG, it's just a a prefix informing us what kind of image this is, and what is the formatting (and a fairly standard one, even browsers can interpret it, but it certainly shouldn't be interpreted as part of the base64 encoded image data).
  3. There was a typo in the variable holding the file pointer from context manager (server_icon_file) and the variable used in body (server_favicon_file).

The snippet originally also didn't contain the code that originally obtained this image, I've included that to make it very clear where the status variable came from.

@ItsDrike ItsDrike added type: bug Something isn't working area: documentation Related to project's documentation (comments, docstrings, docs) labels Jul 17, 2023
docs/pages/faq.rst Outdated Show resolved Hide resolved
@ItsDrike ItsDrike merged commit b255204 into master Jul 17, 2023
@ItsDrike ItsDrike deleted the fix-icon-saving-example branch July 17, 2023 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: documentation Related to project's documentation (comments, docstrings, docs) type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants