import_site: remove obsolete dry run provisionning protection (#51462)
This commit is contained in:
parent
92a9886872
commit
24d42824dd
|
@ -14,7 +14,6 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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())
|
||||
|
|
Loading…
Reference in New Issue