diff options
author | 2022-07-15 13:06:38 +0300 | |
---|---|---|
committer | 2022-07-15 13:33:21 +0300 | |
commit | a77f35b598b227d87db0955a0b2bc97839dcb978 (patch) | |
tree | 5c2759a37f8dad14d9970e432b698326a86db661 /pydis_site/apps/home/views/home.py | |
parent | Add UniqueConstraint to the Filter model (diff) | |
parent | Merge pull request #740 from python-discord/update-django (diff) |
Merge branch 'main' into new-filter-schema
Diffstat (limited to 'pydis_site/apps/home/views/home.py')
-rw-r--r-- | pydis_site/apps/home/views/home.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/pydis_site/apps/home/views/home.py b/pydis_site/apps/home/views/home.py index e28a3a00..9bb1f8fd 100644 --- a/pydis_site/apps/home/views/home.py +++ b/pydis_site/apps/home/views/home.py @@ -1,7 +1,7 @@ import logging from typing import Dict, List -import requests +import httpx from django.core.handlers.wsgi import WSGIRequest from django.http import HttpResponse from django.shortcuts import render @@ -10,7 +10,6 @@ from django.views import View from pydis_site import settings from pydis_site.apps.home.models import RepositoryMetadata -from pydis_site.constants import GITHUB_TOKEN, TIMEOUT_PERIOD log = logging.getLogger(__name__) @@ -43,8 +42,8 @@ class HomeView(View): # specifically, GitHub will reject any requests from us due to the # invalid header. We can make a limited number of anonymous requests # though, which is useful for testing. - if GITHUB_TOKEN: - self.headers = {"Authorization": f"token {GITHUB_TOKEN}"} + if settings.GITHUB_TOKEN: + self.headers = {"Authorization": f"token {settings.GITHUB_TOKEN}"} else: self.headers = {} @@ -57,12 +56,12 @@ class HomeView(View): repo_dict = {} try: # Fetch the data from the GitHub API - api_data: List[dict] = requests.get( + api_data: List[dict] = httpx.get( self.github_api, headers=self.headers, - timeout=TIMEOUT_PERIOD + timeout=settings.TIMEOUT_PERIOD ).json() - except requests.exceptions.Timeout: + except httpx.TimeoutException: log.error("Request to fetch GitHub repository metadata for timed out!") return repo_dict |