Allow debug and verbose modes to be set directly from config.

This commit is contained in:
Vgr E.Barry 2015-01-03 19:33:15 -05:00
parent 555f80eb5e
commit 11b35c79ff

View File

@ -4,17 +4,6 @@ from settings import wolfgame as var
# Todo: Allow game modes to be set via config # Todo: Allow game modes to be set via config
# Carry over settings from botconfig into settings/wolfgame.py
for setting, value in botconfig.__dict__.items():
if not setting.isupper():
continue # Not a setting
if not setting in var.__dict__.keys():
continue # Don't carry over config-only settings
# If we got that far, it's valid
setattr(var, setting, value)
# Handle launch parameters # Handle launch parameters
# Argument --debug means start in debug mode # Argument --debug means start in debug mode
@ -26,8 +15,30 @@ parser.add_argument('--sabotage', action='store_true')
parser.add_argument('--verbose', action='store_true') parser.add_argument('--verbose', action='store_true')
args = parser.parse_args() args = parser.parse_args()
botconfig.DEBUG_MODE = args.debug if not botconfig.DISABLE_DEBUG_MODE else False
botconfig.VERBOSE_MODE = args.verbose debug_mode = args.debug
verbose = args.verbose
sabotage = args.sabotage
# Carry over settings from botconfig into settings/wolfgame.py
for setting, value in botconfig.__dict__.items():
if not setting.isupper():
continue # Not a setting
if setting == "DEBUG_MODE":
debug_mode = value
if setting == "VERBOSE_MODE":
verbose = value
if setting == "DEFAULT_MODULE":
sabotage = value
if not setting in var.__dict__.keys():
continue # Don't carry over config-only settings
# If we got that far, it's valid
setattr(var, setting, value)
botconfig.DEBUG_MODE = debug_mode if not botconfig.DISABLE_DEBUG_MODE else False
botconfig.VERBOSE_MODE = verbose
botconfig.DEFAULT_MODULE = "sabotage" if args.sabotage else "wolfgame" botconfig.DEFAULT_MODULE = "sabotage" if args.sabotage else "wolfgame"