From d0b792b169e1b70f592f0ab01d4407e04fb6fa49 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Fri, 21 Jul 2023 20:50:25 +0200 Subject: Soft fail for upstream error on fetching tag commits Closes #1053 --- pydis_site/apps/content/utils.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'pydis_site/apps/content') diff --git a/pydis_site/apps/content/utils.py b/pydis_site/apps/content/utils.py index 56f6283d..cfd73d67 100644 --- a/pydis_site/apps/content/utils.py +++ b/pydis_site/apps/content/utils.py @@ -1,8 +1,10 @@ import datetime import functools import json +import logging import tarfile import tempfile +from http import HTTPStatus from io import BytesIO from pathlib import Path @@ -18,6 +20,7 @@ from pydis_site import settings from .models import Commit, Tag TAG_CACHE_TTL = datetime.timedelta(hours=1) +log = logging.getLogger(__name__) def github_client(**kwargs) -> httpx.Client: @@ -144,9 +147,26 @@ def set_tag_commit(tag: Tag) -> None: # Fetch and set the commit with github_client() as client: - data = client.get("/repos/python-discord/bot/commits", params={"path": path}) - data.raise_for_status() - data = data.json()[0] + response = client.get("/repos/python-discord/bot/commits", params={"path": path}) + if ( + # We want to hop out early in three cases: + # - We got a forbidden response. (GitHub wrongfully uses this for rate limits.) + # - We got ratelimited. + response.status_code in (HTTPStatus.FORBIDDEN, HTTPStatus.TOO_MANY_REQUESTS) + # - GitHub has unicorn time again and is returning 5xx codes. + or int(response.status_code / 100) == 5 + ): # pragma: no cover + log.warning( + "Received code %d from GitHub for commit history for bot file %r", + response.status_code, path, + ) + # We hop out early because otherwise, these failures may result in the + # overall request to the tag page breaking. + return + + # This should only be permanent issues from here, such as bad requests. + response.raise_for_status() + data = response.json()[0] commit = data["commit"] author, committer = commit["author"], commit["committer"] -- cgit v1.2.3 From f4b4528160a48c0fab49c2719c3b1da9e4e0374b Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Fri, 21 Jul 2023 20:28:47 +0200 Subject: Clean up pragma intended for Python 3.10 removal --- pydis_site/apps/content/views/page_category.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'pydis_site/apps/content') diff --git a/pydis_site/apps/content/views/page_category.py b/pydis_site/apps/content/views/page_category.py index 062c2bc1..1d9a9c39 100644 --- a/pydis_site/apps/content/views/page_category.py +++ b/pydis_site/apps/content/views/page_category.py @@ -56,9 +56,7 @@ class PageOrCategoryView(TemplateView): entry_info["name"] = frontmatter.load(entry).metadata["title"] elif entry.is_dir(): entry_info["name"] = utils.get_category(entry)["title"] - else: # pragma: no cover - # TODO: Remove coverage.py pragma in Python 3.10 - # See: https://github.com/nedbat/coveragepy/issues/198 + else: continue context["subarticles"].append(entry_info) -- cgit v1.2.3 From 80959ab7af347142203d5d4dbd0ce3c471dfe787 Mon Sep 17 00:00:00 2001 From: NipaDev <60810623+Nipa-Code@users.noreply.github.com> Date: Mon, 31 Jul 2023 20:25:54 +0300 Subject: Fix a typo in bot.md (#1058) Fix a typo in bot.md file. Correct the typo "psotgres" to "postgres". --- .../apps/content/resources/guides/pydis-guides/contributing/bot.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pydis_site/apps/content') diff --git a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot.md b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot.md index b5e11a97..f54ee664 100644 --- a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot.md +++ b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot.md @@ -132,7 +132,7 @@ With all of the above setup, you can run The projec with `docker compose up`. Th Some other useful docker commands are as follows: -1. `docker compose pull` this pulls updates for all non-bot services, such as psotgres, redis and our [site](../site) project! +1. `docker compose pull` this pulls updates for all non-bot services, such as postgres, redis and our [site](../site) project! 1. `docker compose build` this rebuilds the bot's docker image, this is only needed if you need to make changes to the bot's dependencies, or the Dockerfile itself. Your bot is now running, all inside Docker. -- cgit v1.2.3 From 45855fe2e3906614490f3577cb50e530423c35b7 Mon Sep 17 00:00:00 2001 From: jchristgit Date: Wed, 2 Aug 2023 11:06:02 +0200 Subject: Capitalize Python outside of tags (#1046) Related to #1044. Co-authored-by: Xithrius <15021300+Xithrius@users.noreply.github.com> --- .../pydis-guides/contributing/bot-extended-configuration-options.md | 2 +- .../content/resources/guides/python-guides/docker-hosting-guide.md | 2 +- pydis_site/templates/events/pages/code-jams/8/_index.html | 4 ++-- pydis_site/templates/events/pages/code-jams/8/frameworks.html | 2 +- pydis_site/templates/events/pages/code-jams/9/_index.html | 2 +- static-builds/README.md | 2 +- static-builds/netlify_build.py | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) (limited to 'pydis_site/apps/content') diff --git a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot-extended-configuration-options.md b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot-extended-configuration-options.md index a35d79a9..f5425d88 100644 --- a/pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot-extended-configuration-options.md +++ b/pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot-extended-configuration-options.md @@ -73,7 +73,7 @@ If you wish to set all values in your `env.server` for your testing server, you **Note**: This is only required when you're not configuring the bot [automatically](#automatic-configuration) -If you will be working on a feature that includes the python help forum, you will need to use `Forum Channels`. +If you will be working on a feature that includes the Python help forum, you will need to use `Forum Channels`. Forum channels cannot be included in a template, which is why this needs to be done by hand for the time being. diff --git a/pydis_site/apps/content/resources/guides/python-guides/docker-hosting-guide.md b/pydis_site/apps/content/resources/guides/python-guides/docker-hosting-guide.md index 57d86e99..7af6a0bb 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/docker-hosting-guide.md +++ b/pydis_site/apps/content/resources/guides/python-guides/docker-hosting-guide.md @@ -26,7 +26,7 @@ description: This guide shows how to host a bot with Docker and GitHub Actions o ## Introduction -Let's say you have got a nice discord bot written in python and you have a VPS to host it on. Now the only question is +Let's say you have got a nice discord bot written in Python and you have a VPS to host it on. Now the only question is how to run it 24/7. You might have been suggested to use *screen multiplexer*, but it has some disadvantages: 1. Every time you update the bot you have to SSH to your server, attach to screen, shutdown the bot, run `git pull` and diff --git a/pydis_site/templates/events/pages/code-jams/8/_index.html b/pydis_site/templates/events/pages/code-jams/8/_index.html index 628a2c22..74e0ad4a 100644 --- a/pydis_site/templates/events/pages/code-jams/8/_index.html +++ b/pydis_site/templates/events/pages/code-jams/8/_index.html @@ -26,7 +26,7 @@

Perceptive Porcupines: WTPython!?

VV, Poppinawhile, ethansocal, Jeff Z, Cohan, ¯\_(ツ)_/¯

- What the Python (wtpython) is a simple terminal user interface that allows you to explore relevant answers on Stackoverflow without leaving your terminal or IDE. When you get an error, all you have to do is swap python for wtpython. When your code hits an error, you'll see a textual interface for exploring relevant answers allowing you to stay focused and ship faster! + What the Python (wtpython) is a simple terminal user interface that allows you to explore relevant answers on Stackoverflow without leaving your terminal or IDE. When you get an error, all you have to do is swap Python for wtpython. When your code hits an error, you'll see a textual interface for exploring relevant answers allowing you to stay focused and ship faster!

Demo video @@ -89,7 +89,7 @@

The Qualifier

The qualifier is a coding challenge that you are required to complete before registering for the code jam. - This is meant as a basic assessment of your skills to ensure you have enough python knowledge to effectively contribute in a team environment. + This is meant as a basic assessment of your skills to ensure you have enough Python knowledge to effectively contribute in a team environment.

View the Qualifier

diff --git a/pydis_site/templates/events/pages/code-jams/8/frameworks.html b/pydis_site/templates/events/pages/code-jams/8/frameworks.html index 1c02e38a..d8fbe96f 100644 --- a/pydis_site/templates/events/pages/code-jams/8/frameworks.html +++ b/pydis_site/templates/events/pages/code-jams/8/frameworks.html @@ -103,7 +103,7 @@

  • Documentation Link
  • Supports: Linux, Mac, and Windows
  • -
  • Pure python library
  • +
  • Pure Python library
diff --git a/pydis_site/templates/events/pages/code-jams/9/_index.html b/pydis_site/templates/events/pages/code-jams/9/_index.html index 3e60c387..5c094b22 100644 --- a/pydis_site/templates/events/pages/code-jams/9/_index.html +++ b/pydis_site/templates/events/pages/code-jams/9/_index.html @@ -75,7 +75,7 @@

The Qualifier

The qualifier is a coding challenge that you are required to complete before registering for the code jam. - This is meant as a basic assessment of your skills to ensure you have enough python knowledge to effectively contribute in a team environment. + This is meant as a basic assessment of your skills to ensure you have enough Python knowledge to effectively contribute in a team environment.

View the Qualifier

diff --git a/static-builds/README.md b/static-builds/README.md index a3c7962b..afd34bb0 100644 --- a/static-builds/README.md +++ b/static-builds/README.md @@ -42,7 +42,7 @@ Publish Directory: | Name | Value | Description | |----------------|--------------------------------|-------------------------------------------------------------------------------------------| -| PYTHON_VERSION | 3.8 | The python version. Supported options are defined by netlify [here][netlify build image]. | +| PYTHON_VERSION | 3.8 | The Python version. Supported options are defined by netlify [here][netlify build image]. | | API_URL | https://pythondiscord.com/ | The link to the API, which will be used to fetch the build artifacts. | | ACTION_NAME | Build & Publish Static Preview | The name of the workflow which will be used to find the artifact. | | ARTIFACT_NAME | static-build | The name of the artifact to download. | diff --git a/static-builds/netlify_build.py b/static-builds/netlify_build.py index 2d311a11..4d4a613d 100644 --- a/static-builds/netlify_build.py +++ b/static-builds/netlify_build.py @@ -1,6 +1,6 @@ """Build script to deploy project on netlify.""" -# WARNING: This file must remain compatible with python 3.8 +# WARNING: This file must remain compatible with Python 3.8 # This script performs all the actions required to build and deploy our project on netlify # It depends on the following packages, which are set in the netlify UI: -- cgit v1.2.3