Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print("Running", self._test_name)
# This setup is done in run() because we need to give control to the
# kivy event loop which we can only do by returning from the run()
# that's called. So we override run() and setup mpf-mc and then call
# our own run_test() on a callback. Then we can wait until the
# environment is setup (which can take a few frames), then we call
# super().run() to get the actual TestCase.run() method to run and
# we return the results.
# We have to do this in run() and not setUp() because run actually
# calls setUp(), so since we were overriding it ours doesn't call it
# so we just do our setup here since if we manually called setUp() then
# it would be called again when we call super().run().
mpf_config = ConfigProcessor.load_config_file(self.get_options()[
'mcconfigfile'])
mpf_config = load_machine_config(
Util.string_to_list(self.get_config_file()),
self.get_machine_path(),
mpf_config['mpf-mc']['paths']['config'], mpf_config)
self.preprocess_config(mpf_config)
self.mc = TestMpfMc(options=self.get_options(),
config=mpf_config,
machine_path=self.get_machine_path())
self.patch_bcp()
from kivy.core.window import Window
Window.create_window()
self.log.info("Loading config from original files")
self.config = self._get_mpf_config()
self.config['_mpf_version'] = __version__
for num, config_file in enumerate(self.options['configfile']):
if not (config_file.startswith('/') or
config_file.startswith('\\')):
config_file = os.path.join(self.machine_path, self.config['mpf']['paths']['config'], config_file)
self.log.info("Machine config file #%s: %s", num + 1, config_file)
self.config = Util.dict_merge(self.config,
ConfigProcessor.load_config_file(
config_file,
config_type='machine'))
self.machine_config = self.config
if self.options['create_config_cache']:
self._cache_config()
def _get_mpf_config(self):
return ConfigProcessor.load_config_file(self.options['mpfconfigfile'],
config_type='machine')
self.log.info("Loading config from original files")
self.config = self._get_mpf_config()
self.config['_mpf_version'] = __version__
for num, config_file in enumerate(self.options['configfile']):
if not (config_file.startswith('/') or
config_file.startswith('\\')):
config_file = os.path.join(self.machine_path, self.config['mpf']['paths']['config'], config_file)
self.log.info("Machine config file #%s: %s", num + 1, config_file)
self.config = Util.dict_merge(self.config,
ConfigProcessor.load_config_file(
config_file,
config_type='machine'))
self.machine_config = self.config
if self.options['create_config_cache']:
self._cache_config()
if not os.path.exists(mode_path):
mode_path = os.path.join(
self.machine.mpf_path,
self.machine.config['mpf']['paths']['modes'], mode_string)
# Is there an MPF default config for this mode? If so, load it first
mpf_mode_config = os.path.join(
self.machine.mpf_path,
self.machine.config['mpf']['paths']['modes'],
mode_string,
'config',
mode_string + '.yaml')
if os.path.isfile(mpf_mode_config):
config = ConfigProcessor.load_config_file(mpf_mode_config)
found_configuration = True
# Now figure out if there's a machine-specific config for this mode,
# and if so, merge it into the config
mode_config_file = os.path.join(self.machine.machine_path,
self.machine.config['mpf']['paths']['modes'],
mode_string, 'config', mode_string + '.yaml')
if os.path.isfile(mode_config_file):
config = Util.dict_merge(config,
ConfigProcessor.load_config_file(mode_config_file))
found_configuration = True
# the mode has to have at least one config to exist
if not found_configuration:
except KeyError:
pass
# Now figure out if there's a machine-specific config for this mode,
# and if so, merge it into the config
try:
mode_config_file = os.path.join(
self.machine.machine_path,
self.machine.config['mpf']['paths']['modes'],
self._machine_mode_folders[mode_string],
'config',
self._machine_mode_folders[mode_string] + '.yaml')
if os.path.isfile(mode_config_file):
config = Util.dict_merge(config,
ConfigProcessor.load_config_file(
mode_config_file, 'mode'))
if self.debug:
self.log.debug("Loading config from %s", mode_config_file)
except KeyError:
pass
# validate config
if 'mode' not in config:
config['mode'] = dict()
return config