Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
Refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
Ria Jha committed Jun 14, 2018
1 parent b3f4762 commit 24fb51d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
16 changes: 7 additions & 9 deletions aimmo_runner/minikube.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def create_creator_yaml():
"""
orig_path = os.path.join(BASE_DIR, 'aimmo-game-creator', 'rc-aimmo-game-creator.yaml')
with open(orig_path) as orig_file:
content = yaml.safe_load(orig_file.read().replace('latest', 'test').replace('REPLACE_ME', 'http://%s:8000/players/api/games/' % get_ip()))
content = yaml.safe_load(orig_file.read().replace('latest', 'test').replace('REPLACE_ME',
'http://%s:8000/players/api/games/' % get_ip()))
return content


Expand All @@ -74,14 +75,11 @@ def start_cluster(minikube):
Starts the cluster unless it has been already started by the user.
:param minikube: Executable minikube installed beforehand.
"""
try:
status = run_command([minikube, 'status'], True)
if 'minikube: Running' in status:
print('Cluster already running')
else:
run_command([minikube, 'start', '--memory=2048', '--cpus=2'])
except:
pass
status = run_command([minikube, 'status'], True)
if 'minikube: Running' in status:
print('Cluster already running')
else:
run_command([minikube, 'start', '--memory=2048', '--cpus=2'])


def create_docker_client(raw_env_settings):
Expand Down
10 changes: 3 additions & 7 deletions players/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.utils.module_loading import import_string
from permissions import default_preview_user
from django.contrib.auth.models import User
import logging

#: URL function for locating the game server, takes one parameter `game`
GAME_SERVER_URL_FUNCTION = getattr(settings, 'AIMMO_GAME_SERVER_URL_FUNCTION', None)
Expand All @@ -16,19 +15,16 @@ def get_aimmo_preview_user_decorator():
if PREVIEW_USER_AIMMO_DECORATOR:
func = import_string(PREVIEW_USER_AIMMO_DECORATOR)
return func
else:
return default_preview_user
return default_preview_user


def get_users_for_new_game_function(request):
def get_users_for_new_game(request):
if USERS_FOR_NEW_AIMMO_GAME:
func = import_string(USERS_FOR_NEW_AIMMO_GAME)
return func(request)
else:
return User.objects.all()
return User.objects.all()


preview_user = get_aimmo_preview_user_decorator()
get_users_for_new_game = getattr(settings, 'USERS_FOR_NEW_AIMMO_GAME_FUNCTION', get_users_for_new_game_function)

MAX_LEVEL = 1
4 changes: 2 additions & 2 deletions players/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from models import Avatar, Game, LevelAttempt
from players import forms
from . import app_settings
from app_settings import get_users_for_new_game_function
from app_settings import get_users_for_new_game

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -179,7 +179,7 @@ def add_game(request):
game.owner = request.user
game.main_user = request.user
game.save()
users = get_users_for_new_game_function(request)
users = get_users_for_new_game(request)
if users is not None:
game.can_play.add(*users)
return redirect('aimmo/program', id=game.id)
Expand Down

0 comments on commit 24fb51d

Please sign in to comment.