Skip to content

Commit

Permalink
Merge branch 'feature/ajustement_go_kick' of https://github.com/RoboC…
Browse files Browse the repository at this point in the history
…upULaval/StrategyAI into feature/ajustement_go_kick
  • Loading branch information
wonwon0 committed Jun 15, 2018
2 parents d51d431 + 74c7e83 commit 9ad971b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
27 changes: 27 additions & 0 deletions Util/sysinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

import os
import subprocess

# Return the git revision as a string
def git_version():
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH']:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
return out

try:
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
git_revision = out.strip().decode('ascii')
except OSError:
git_revision = 'Unknown'

return git_revision
10 changes: 7 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from Engine.Framework import Framework
from config.config import Config
from Util.sysinfo import git_version


def set_arg_parser():
Expand Down Expand Up @@ -55,22 +56,25 @@ def set_arg_parser():


if __name__ == '__main__':
cli_args = set_arg_parser().parse_args()
Config().load_file(cli_args.config_file)
Config().load_parameters(cli_args)

consoleFormatter = logging.Formatter('[%(levelname)-5.5s] - %(name)-22.22s: %(message)s')
consoleHandler = logging.StreamHandler(stream=stdout)
consoleHandler.setFormatter(consoleFormatter)

logging.basicConfig(level=logging.NOTSET, handlers=[consoleHandler])

cli_args = set_arg_parser().parse_args()
Config().load_file(cli_args.config_file)
Config().load_parameters(cli_args)

logger = logging.getLogger('Main')

logger.info('Color: {}, Field side: {}, Mode: {}'.format(Config()['GAME']['our_color'].upper(),
'NEGATIVE' if Config()['GAME']['on_negative_side'] else 'POSITIVE',
'COMPETITION' if cli_args.competition_mode else 'NORMAL'))

logger.info('Current git commit hash: ' + git_version())

stop_framework = False
while not stop_framework:
try:
Expand Down

0 comments on commit 9ad971b

Please sign in to comment.