aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2023-08-09 18:11:08 +0100
committerGravatar GitHub <[email protected]>2023-08-09 18:11:08 +0100
commita74b755c9bce4ac37394be6e0dcf947cbbbf81fb (patch)
treea33832d245171c82fd8747f555aea4f6d29821c9 /pydis_site/apps
parentMove commit model into its own file (diff)
parentMerge pull request #1068 from python-discord/dependabot/pip/ruff-0.0.283 (diff)
Merge branch 'main' into move-commit-model-to-proper-module
Diffstat (limited to 'pydis_site/apps')
-rw-r--r--pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot-extended-configuration-options.md2
-rw-r--r--pydis_site/apps/content/resources/guides/pydis-guides/contributing/bot.md2
-rw-r--r--pydis_site/apps/content/resources/guides/python-guides/docker-hosting-guide.md2
-rw-r--r--pydis_site/apps/content/utils.py26
-rw-r--r--pydis_site/apps/content/views/page_category.py4
5 files changed, 27 insertions, 9 deletions
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/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.
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/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"]
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)