def handle(self, *args, **options): for world_id in options['world_id']: try: world = World.objects.get(pk=world_id) except World.DoesNotExist: raise CommandError('World with id "%s" does not exist' % world_id) try: with perf_timer('World "%s" initialization' % world_id): initialize_world(world) except AlreadyInitializedException: raise CommandError( 'World with id "%s" is already initialized' % world_id) self.stdout.write( self.style.SUCCESS('Successfully initialized world "%s"' % world_id))
def handle(self, *args, **options): logging.getLogger().setLevel(logging.INFO) for world_id in options['world_id']: try: world = World.objects.get(pk=world_id) except World.DoesNotExist: raise CommandError( 'World with id {} does not exist'.format(world_id)) try: initialize_world(world) except AlreadyInitializedException: raise CommandError('{} ({}) is already initialized'.format( world, world_id)) self.stdout.write( self.style.SUCCESS('Successfully initialized {} ({})'.format( world, world_id)))
def initialize_world_admin_action(modeladmin, request, queryset): for world in queryset.all(): initialize_world(world)
def test_initialization(self): initialize_world(World.objects.get(id=1))