def execute_args(args): """Execute args.which command :param args: argparse args :return: None """ if not getattr(args, 'which', None) or args.which == 'run': Listener(args.config).run(root_allowed=args.root_allowed) elif args.which == 'check-config': check_config(args.config) elif args.which == 'test-device': test_device(args.device, args.config, args.root_allowed) elif args.which == 'discovery': from amazon_dash.discovery import discover discover()
def execute_from_command_line(argv=None): """ A simple method that runs a ManagementUtility. """ parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--config', default=CONFIG_FILE, help='Path to config file.') parser.add_argument('--warning', help='set logging to warning', action='store_const', dest='loglevel', const=logging.WARNING, default=logging.INFO) parser.add_argument('--quiet', help='set logging to ERROR', action='store_const', dest='loglevel', const=logging.ERROR, default=logging.INFO) parser.add_argument('--debug', help='set logging to DEBUG', action='store_const', dest='loglevel', const=logging.DEBUG, default=logging.INFO) parser.add_argument('--verbose', help='set logging to COMM', action='store_const', dest='loglevel', const=5, default=logging.INFO) parser.sub = parser.add_subparsers() parse_service = parser.sub.add_parser('discovery', help='Discover Amazon Dash device on network.') parse_service.set_defaults(which='discovery') parse_oneshot = parser.sub.add_parser('run', help='Run server') parse_oneshot.set_defaults(which='run') parse_oneshot.add_argument('--root-allowed', action='store_true') parser.set_default_subparser('run') args = parser.parse_args(argv[1:]) create_logger('amazon-dash', args.loglevel) if not getattr(args, 'which', None) or args.which == 'run': Listener(args.config).run(root_allowed=args.root_allowed) elif args.which == 'discovery': from amazon_dash.discovery import discover discover()
def discovery(): from amazon_dash.discovery import discover discover()
def discovery(interface): from amazon_dash.discovery import discover discover(interface)