fix-v0.2
Tom Wilson 5 years ago
parent 82cc667cbb
commit 9781d7f77b

@ -169,30 +169,29 @@ def compile_config(default_config_path):
return core_conf, plugin_classes, plugin_configs return core_conf, plugin_classes, plugin_configs
@click.group(invoke_without_command = True) @click.group(invoke_without_command=True)
#help="Path to default config TOML file" #help="Path to default config TOML file"
@click.argument('default_config', default="shepherd-default.toml", type=click.Path()) @click.argument('default_config', default="shepherd-default.toml", type=click.Path())
@click.pass_context @click.pass_context
def cli(ctx, default_config): def cli(ctx, default_config):
""" """
Core service. Expects the default config to be set as an argument. Core service. Expects the default config to be set as an argument.
""" """
#argparser = argparse.ArgumentParser(description="Keep track of a mob " # argparser = argparse.ArgumentParser(description="Keep track of a mob "
# "of roaming Pis") # "of roaming Pis")
#argparser.add_argument("configfile", nargs='?', metavar="configfile", # argparser.add_argument("configfile", nargs='?', metavar="configfile",
# help="Path to configfile", default="shepherd.toml") # help="Path to configfile", default="shepherd.toml")
#argparser.add_argument( # argparser.add_argument(
# '-e', '--noedit', help="Disable the editable config temporarily", action="store_true", default=False) # '-e', '--noedit', help="Disable the editable config temporarily", action="store_true", default=False)
#argparser.add_argument("-t", "--test", help="Test and interface function of the from 'plugin:function'", # argparser.add_argument("-t", "--test", help="Test and interface function of the from 'plugin:function'",
# default=None) # default=None)
#args = argparser.parse_args() #args = argparser.parse_args()
core_conf, plugin_classes, plugin_configs = compile_config(default_config) core_conf, plugin_classes, plugin_configs = compile_config(default_config)
if args.test is None: # if args.test is None:
control.init_control(core_conf, plugin_configs) # control.init_control(core_conf, plugin_configs)
scheduler.init_scheduler(core_conf) scheduler.init_scheduler(core_conf)
plugin.init_plugins(plugin_classes, plugin_configs, core_conf) plugin.init_plugins(plugin_classes, plugin_configs, core_conf)
@ -209,11 +208,11 @@ def cli(ctx, default_config):
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit):
pass pass
@click.argument('plugin_function') @click.argument('plugin_function')
@cli.command() @cli.command()
def test(): def test(plugin_function):
if args.test is not None: (test_plugin, test_func) = plugin_function.split(':')
(test_plugin, test_func) = args.test.split(':') func = getattr(plugin.plugin_functions[test_plugin], test_func)
func = getattr(shepherd.plugin.plugin_functions[test_plugin], test_func) print(func())
print(func()) return
return

Loading…
Cancel
Save