|
| 1 | +import logging |
1 | 2 | import os |
2 | 3 | import re |
3 | 4 | import sys |
|
6 | 7 | from dotenv import load_dotenv |
7 | 8 | from httpx import Client, HTTPStatusError, Response |
8 | 9 |
|
9 | | -from bot.constants import Webhooks, _Categories, _Channels, _Roles |
10 | | -from bot.log import get_logger |
| 10 | +# Filter out the send typing monkeypatch logs from bot core when we import to get constants |
| 11 | +logging.getLogger("pydis_core").setLevel(logging.WARNING) |
| 12 | + |
| 13 | +from bot.constants import Webhooks, _Categories, _Channels, _Roles # noqa: E402 |
| 14 | +from bot.log import get_logger # noqa: E402 |
11 | 15 |
|
12 | 16 | load_dotenv() |
13 | | -log = get_logger("Config Bootstrapper") |
| 17 | +log = get_logger("botstrap") |
| 18 | +# Silence noisy httpcore logger |
| 19 | +get_logger("httpcore").setLevel("INFO") |
14 | 20 |
|
15 | 21 | env_file_path = Path(".env.server") |
16 | 22 | BOT_TOKEN = os.getenv("BOT_TOKEN", None) |
@@ -51,10 +57,10 @@ def __getitem__(self, item: str): |
51 | 57 | try: |
52 | 58 | return super().__getitem__(item) |
53 | 59 | except KeyError: |
54 | | - log.warning(f"Couldn't find key: {item} in dict: {self.name} ") |
| 60 | + log.fatal(f"Couldn't find key: {item} in dict: {self.name}") |
55 | 61 | log.warning( |
56 | | - "Please make sure to follow our contribution guideline " |
57 | | - "https://www.pythondiscord.com/pages/guides/pydis-guides/contributing/bot/ " |
| 62 | + "Please follow our contribution guidelines " |
| 63 | + "https://pydis.com/contributing-bot " |
58 | 64 | "to guarantee a successful run of botstrap " |
59 | 65 | ) |
60 | 66 | sys.exit(-1) |
@@ -85,7 +91,7 @@ def upgrade_server_to_community_if_necessary( |
85 | 91 | payload = response.json() |
86 | 92 |
|
87 | 93 | if COMMUNITY_FEATURE not in payload["features"]: |
88 | | - log.warning("This server is currently not a community, upgrading.") |
| 94 | + log.info("This server is currently not a community, upgrading.") |
89 | 95 | payload["features"].append(COMMUNITY_FEATURE) |
90 | 96 | payload["rules_channel_id"] = rules_channel_id_ |
91 | 97 | payload["public_updates_channel_id"] = announcements_channel_id_ |
@@ -251,3 +257,5 @@ def create_webhook(self, name: str, channel_id_: int) -> str: |
251 | 257 |
|
252 | 258 | with env_file_path.open("wb") as file: |
253 | 259 | file.write(config_str.encode("utf-8")) |
| 260 | + |
| 261 | + log.info("Botstrap completed successfully. Configuration has been written to %s", env_file_path) |
0 commit comments