Compare commits

..

5 Commits
3.2.0 ... 3.2.1

Author SHA1 Message Date
Michael H
5bd044d646 3.2.1 Hotfix (#3321) 2020-01-10 00:10:59 -05:00
Michael H
371292e03a prevent an empty iterable issue (#3320) 2020-01-10 00:04:12 -05:00
Michael H
acc5baec7d possible mongo fix (#3319)
* possible mongo fix

* prevent swallowing the exception

* better log str
2020-01-09 23:56:05 -05:00
Michael H
ed692bcaa5 This shouldn't be possible normally, but we've have enough issues with it (#3318) 2020-01-09 19:20:34 -09:00
Michael H
7352f76b87 mark dev (#3315) 2020-01-09 22:36:45 -05:00
7 changed files with 57 additions and 9 deletions

View File

@@ -1,3 +1,16 @@
.. 3.2.x Changelogs
Redbot 3.2.1 (2020-01-10)
=========================
Hotfixes
--------
- Fix Mongo conversion from being incorrectly blocked
- Fix announcer not creating a message for success feedback
- Log an error with creating case types rather than crash
Redbot 3.2.0 (2020-01-09)
=========================
Core Bot Changes

View File

@@ -193,7 +193,7 @@ def _update_event_loop_policy():
_asyncio.set_event_loop_policy(_uvloop.EventLoopPolicy())
__version__ = "3.2.0"
__version__ = "3.2.1"
version_info = VersionInfo.from_str(__version__)
# Filter fuzzywuzzy slow sequence matcher warning

View File

@@ -466,6 +466,10 @@ def main():
log.info("Shutting down with exit code: %s", exc.code)
if red is not None:
loop.run_until_complete(shutdown_handler(red, None, exc.code))
except Exception as exc: # Non standard case.
log.exception("Unexpected exception (%s): ", type(exc), exc_info=exc)
if red is not None:
loop.run_until_complete(shutdown_handler(red, None, ExitCodes.CRITICAL))
finally:
# Allows transports to close properly, and prevent new ones from being opened.
# Transports may still not be closed correcly on windows, see below

View File

@@ -75,6 +75,7 @@ class Announcer:
if len(failed) == 1
else _("I could not announce to the following servers: ")
)
if failed:
msg += humanize_list(tuple(map(inline, failed)))
await self.ctx.bot.send_to_owners(msg)
self.active = False

View File

@@ -643,7 +643,14 @@ class Config:
return pickle.loads(pickle.dumps(self._defaults, -1))
@classmethod
def get_conf(cls, cog_instance, identifier: int, force_registration=False, cog_name=None):
def get_conf(
cls,
cog_instance,
identifier: int,
force_registration=False,
cog_name=None,
allow_old: bool = False,
):
"""Get a Config instance for your cog.
.. warning::
@@ -676,11 +683,16 @@ class Config:
A new Config object.
"""
if allow_old:
log.warning(
"DANGER! This is getting an outdated driver. "
"Hopefully this is only being done from convert"
)
uuid = str(identifier)
if cog_name is None:
cog_name = type(cog_instance).__name__
driver = get_driver(cog_name, uuid)
driver = get_driver(cog_name, uuid, allow_old=allow_old)
if hasattr(driver, "migrate_identifier"):
driver.migrate_identifier(identifier)
@@ -693,7 +705,7 @@ class Config:
return conf
@classmethod
def get_core_conf(cls, force_registration: bool = False):
def get_core_conf(cls, force_registration: bool = False, allow_old: bool = False):
"""Get a Config instance for the core bot.
All core modules that require a config instance should use this
@@ -706,7 +718,11 @@ class Config:
"""
return cls.get_conf(
None, cog_name="Core", identifier=0, force_registration=force_registration
None,
cog_name="Core",
identifier=0,
force_registration=force_registration,
allow_old=allow_old,
)
def __getattr__(self, item: str) -> Union[Group, Value]:
@@ -1457,7 +1473,7 @@ class Config:
async def migrate(cur_driver_cls: Type[BaseDriver], new_driver_cls: Type[BaseDriver]) -> None:
"""Migrate from one driver type to another."""
# Get custom group data
core_conf = Config.get_core_conf()
core_conf = Config.get_core_conf(allow_old=True)
core_conf.init_custom("CUSTOM_GROUPS", 2)
all_custom_group_data = await core_conf.custom("CUSTOM_GROUPS").all()

View File

@@ -73,7 +73,12 @@ def get_driver_class(storage_type: Optional[BackendType] = None) -> Type[BaseDri
def get_driver(
cog_name: str, identifier: str, storage_type: Optional[BackendType] = None, **kwargs
cog_name: str,
identifier: str,
storage_type: Optional[BackendType] = None,
*,
allow_old: bool = False,
**kwargs,
):
"""Get a driver instance.
@@ -107,7 +112,10 @@ def get_driver(
storage_type = BackendType.JSON
try:
if not allow_old:
driver_cls: Type[BaseDriver] = get_driver_class(storage_type)
else:
driver_cls: Type[BaseDriver] = _get_driver_class_include_old(storage_type)
except ValueError:
if storage_type in (BackendType.MONGOV1, BackendType.MONGO):
raise RuntimeError(

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
import asyncio
import logging
from datetime import datetime, timedelta
from typing import List, Union, Optional, cast, TYPE_CHECKING
@@ -21,6 +22,8 @@ from .generic_casetypes import all_generics
if TYPE_CHECKING:
from redbot.core.bot import Red
log = logging.getLogger("red.core.modlog")
__all__ = [
"Case",
"CaseType",
@@ -497,12 +500,15 @@ class CaseType:
image: str,
case_str: str,
guild: Optional[discord.Guild] = None,
**kwargs,
):
self.name = name
self.default_setting = default_setting
self.image = image
self.case_str = case_str
self.guild = guild
if kwargs:
log.warning("Got unexpected keys in case %s", ",".join(kwargs.keys()))
async def to_json(self):
"""Transforms the case type into a dict and saves it"""