Skip to content

Commit

Permalink
implement hardware scan command
Browse files Browse the repository at this point in the history
  • Loading branch information
jabdoa2 committed Jan 28, 2018
1 parent 8a7f42a commit 2a58e98
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mpf/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,18 @@ def execute(self):

_module = import_module('mpf.commands.%s' % command)

if hasattr(_module, "subcommand") and _module.subcommand:
subcommand = self.argv.pop(1)
else:
subcommand = None

machine_path, remaining_args = self.parse_args()

_module.Command(self.mpf_path, machine_path, remaining_args)
obj = _module.Command(self.mpf_path, machine_path, remaining_args)

if subcommand is not None:
method = getattr(obj, subcommand)
method()

def parse_args(self):
"""Parse command line arguments."""
Expand Down
34 changes: 34 additions & 0 deletions mpf/commands/hardware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Perform hardware operations."""
import os

from mpf.core.machine import MachineController

subcommand = True


class Command(object):

"""Performs hardware operations."""

def __init__(self, mpf_path, machine_path, args):
"""Parse args."""
self.mpf_path = mpf_path
self.machine_path = machine_path
self.args = args
self.mpf = MachineController(self.mpf_path, self.machine_path,
{"bcp": False,
"no_load_cache": False,
"mpfconfigfile": os.path.join(mpf_path, "mpfconfig.yaml"),
"configfile": ["config"],
"create_config_cache": False,
"force_platform": False,
"text_ui": False
})
self.mpf.initialise_mpf()

def scan(self):
"""Scan hardware."""
for name, platform in self.mpf.hardware_platforms.items():
print("{}:".format(name))
print(platform.get_info_string())
print("---------")

0 comments on commit 2a58e98

Please sign in to comment.