From fe39881b6ad7161a143474d057409bc2ebea22da Mon Sep 17 00:00:00 2001 From: Valentin Deniaud Date: Tue, 25 May 2021 15:00:53 +0200 Subject: [PATCH] import_site: remove obsolete dry run provisionning protection (#51462) --- .../management/commands/import_site.py | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/authentic2/management/commands/import_site.py b/src/authentic2/management/commands/import_site.py index 90283387..22a57943 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()) -- 2.20.1