Example #1
0
 def test_success(self):
     file = 'amazon-dash.yml'
     with Patcher() as patcher:
         patcher.fs.CreateFile(file, contents=config_data)
         os.chown(file, 0, 0)
         os.chmod(file, 0o600)
         check_config(file, lambda x: x)
Example #2
0
 def test_fail(self):
     file = 'amazon-dash.yml'
     with Patcher() as patcher:
         patcher.fs.CreateFile(file, contents='invalid config')
         os.chown(file, 0, 0)
         os.chmod(file, 0o600)
         with self.assertRaises(InvalidConfig):
             check_config(file)
Example #3
0
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()
Example #4
0
def check_config(config):
    from amazon_dash.config import check_config
    check_config(config)