diff --git a/src/authentic2/management/commands/import_site.py b/src/authentic2/management/commands/import_site.py index 902833874..22a579432 100644 --- a/src/authentic2/management/commands/import_site.py +++ b/src/authentic2/management/commands/import_site.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import contextlib import json import sys @@ -42,18 +41,6 @@ def create_context_args(options): return kwargs -# Borrowed from https://bugs.python.org/issue10049#msg118599 -@contextlib.contextmanager -def provision_contextm(dry_run, settings): - if dry_run and 'hobo.agent.authentic2' in settings.INSTALLED_APPS: - import hobo.agent.authentic2 - - with hobo.agent.authentic2.provisionning.Provisionning(): - yield - else: - yield - - class Command(BaseCommand): help = 'Import site' @@ -83,12 +70,11 @@ class Command(BaseCommand): c_kwargs = create_context_args(options) try: with open(filename, 'r') as f: - with provision_contextm(dry_run, settings): - with transaction.atomic(): - sys.stdout.write(msg) - result = import_site(json.load(f), ImportContext(**c_kwargs)) - if dry_run: - raise DryRunException() + with transaction.atomic(): + sys.stdout.write(msg) + result = import_site(json.load(f), ImportContext(**c_kwargs)) + if dry_run: + raise DryRunException() except DryRunException: pass sys.stdout.write(result.to_str())