When writing config, make containing directory if necessary. Also default to tighter permissions.

This commit is contained in:
Dan Helfman 2017-07-10 15:20:50 -07:00
commit 61f88228b0
2 changed files with 27 additions and 7 deletions

View file

@ -42,7 +42,7 @@ def parse_arguments(*arguments):
def main(): # pragma: no cover
try:
# TODO: Detect whether only legacy config is present. If so, inform the user about how to
# upgrade, then exet.
# upgrade, then exit.
args = parse_arguments(*sys.argv[1:])
config = parse_configuration(args.config_filename, schema_filename())

View file

@ -87,8 +87,11 @@ def main(): # pragma: no cover
destination_config = convert.convert_legacy_parsed_config(source_config, source_excludes, schema)
generate.write_configuration(args.destination_config_filename, destination_config)
os.chmod(args.destination_config_filename, source_config_file_mode)
generate.write_configuration(
args.destination_config_filename,
destination_config,
mode=source_config_file_mode,
)
# TODO: As a backstop, check that the written config can actually be read and parsed, and
# that it matches the destination config data structure that was written.