Skip to content

Commit

Permalink
#9 get bot credentials from env
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleVasya committed Dec 15, 2016
1 parent d01f5d7 commit 7ac62e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 6 additions & 3 deletions app/balancer/management/commands/dota_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ def add_arguments(self, parser):
def handle(self, *args, **options):
bots_num = options['number']

bot_login = os.environ.get('BOT_LOGIN', '')
bot_password = os.environ.get('BOT_PASSWORD', '')
credentials = [
{
'login': 'login%d' % i,
'password': 'password%d' % i,
'login': '%s%d' % (bot_login, i),
'password': '%s%d' % (bot_password, i),
} for i in xrange(1, bots_num+1)
]

Expand Down Expand Up @@ -121,7 +123,8 @@ def create_new_lobby(self, bot):

bot.balance_answer = None

bot.create_practice_lobby(password='eu', options={
lobby_password = os.environ.get('LOBBY_PASSWORD', '')
bot.create_practice_lobby(password=lobby_password, options={
'game_name': 'Inhouse Ladder',
'game_mode': dota2.enums.DOTA_GameMode.DOTA_GAMEMODE_CD,
'server_region': int(dota2.enums.EServerRegion.Europe),
Expand Down
12 changes: 9 additions & 3 deletions app/balancer/management/commands/dota_test_bots.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.core.management.base import BaseCommand
import gevent
import dota2
import os
from steam import SteamClient
from dota2 import Dota2Client

Expand All @@ -13,19 +14,24 @@ def __init__(self):

def add_arguments(self, parser):
parser.add_argument('-l', '--lobby', type=int)

lobby_password = os.environ.get('LOBBY_PASSWORD', '')
parser.add_argument('-p', '--password',
nargs='?', type=str, default='eu', const='eu')
nargs='?', type=str,
default=lobby_password, const=lobby_password)

def handle(self, *args, **options):
self.lobby = options['lobby']
self.password = options['password']

bots_num = 9

bot_login = os.environ.get('BOT_LOGIN', '')
bot_password = os.environ.get('BOT_PASSWORD', '')
credentials = [
{
'login': 'login%d' % i,
'password': 'password%d' % i,
'login': '%s%d' % (bot_login, i),
'password': '%s%d' % (bot_password, i),
} for i in xrange(2, bots_num+2)
]

Expand Down

0 comments on commit 7ac62e8

Please sign in to comment.