Skip to content
Snippets Groups Projects
Commit 56199942 authored by Roang's avatar Roang
Browse files

FIx _ScheduleTypeManager

Raise a warning instead of an exception when a duplicate import is found.
Additionally log the error.
parent becfa667
No related branches found
No related tags found
1 merge request!1227Remove unused features
import logging import logging
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from datetime import timedelta from datetime import timedelta
from warnings import warn
from django.conf import settings from django.conf import settings
from django.utils import timezone from django.utils import timezone
...@@ -172,7 +173,8 @@ class _ScheduleTypeManager: ...@@ -172,7 +173,8 @@ class _ScheduleTypeManager:
if klass_ident in self.types: if klass_ident in self.types:
if self.types[klass_ident] == klass: if self.types[klass_ident] == klass:
raise RuntimeWarning(f'Duplicate import of {line} for schedule support "{klass_ident}".') warn('Duplicate import of %s for schedule support "%s".', line, klass_ident)
self._logger.error('Duplicate import of %s for schedule support "%s".', line, klass_ident)
continue continue
raise ImportError(f'The identifier "{klass_ident}" of "{line}" is already in use by "{self.types[klass_ident]}".') raise ImportError(f'The identifier "{klass_ident}" of "{line}" is already in use by "{self.types[klass_ident]}".')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment