def runrestic() -> None: if not restic_check(): return args, extras = cli_arguments() configure_logging(args.log_level) configure_signals() if args.config_file: config_file_paths = [args.config_file] else: config_file_paths = list(configuration_file_paths()) if not len(config_file_paths): raise FileNotFoundError( f"Error: No configuration files found in {possible_config_paths()}" ) configs: List[Dict[str, Any]] = [] for c in config_file_paths: parsed_cfg = parse_configuration(c) if parsed_cfg: configs += [parsed_cfg] if "shell" in args.actions: restic_shell(configs) return for config in configs: runner = ResticRunner(config, args, extras) runner.run()
def test_configuration_file_paths_wrong_perms(caplog, restic_dir): bad_perms_file = restic_dir.join("example.toml") bad_perms_file.write("irrelevant") os.chmod(bad_perms_file, 0o0644) paths = list(configuration_file_paths()) assert paths == [] assert f"NOT using {bad_perms_file}." in caplog.text assert "File permissions are too open (0644)" in caplog.text
def test_configuration_file_paths(restic_minimal_good_conf): paths = list(configuration_file_paths()) assert paths == [restic_minimal_good_conf]