Esempio n. 1
0
def main():  # pragma: no cover
    try:
        args = parse_arguments(*sys.argv[1:])

        generate.generate_sample_configuration(args.source_filename,
                                               args.destination_filename,
                                               validate.schema_filename())

        print('Generated a sample configuration file at {}.'.format(
            args.destination_filename))
        print()
        if args.source_filename:
            print('Merged in the contents of configuration file at {}.'.format(
                args.source_filename))
            print('To review the changes made, run:')
            print()
            print('    diff --unified {} {}'.format(args.source_filename,
                                                    args.destination_filename))
            print()
        print(
            'Please edit the file to suit your needs. The values are representative.'
        )
        print('All fields are optional except where indicated.')
        print()
        print('If you ever need help: https://torsion.org/borgmatic/#issues')
    except (ValueError, OSError) as error:
        print(error, file=sys.stderr)
        sys.exit(1)
Esempio n. 2
0
def test_generate_sample_configuration_does_not_raise():
    builtins = flexmock(sys.modules['builtins'])
    builtins.should_receive('open').with_args('schema.yaml').and_return('')
    flexmock(module).should_receive('write_configuration')
    flexmock(module).should_receive('_schema_to_sample_configuration')

    module.generate_sample_configuration('config.yaml', 'schema.yaml')
Esempio n. 3
0
def test_generate_sample_configuration_does_not_raise():
    builtins = flexmock(sys.modules['builtins'])
    builtins.should_receive('open').with_args('schema.yaml').and_return('')
    flexmock(module).should_receive('_schema_to_sample_configuration')
    flexmock(module).should_receive('_render_configuration')
    flexmock(module).should_receive('_comment_out_optional_configuration')
    flexmock(module).should_receive('write_configuration')

    module.generate_sample_configuration('config.yaml', 'schema.yaml')
Esempio n. 4
0
def test_generate_sample_configuration_does_not_raise():
    builtins = flexmock(sys.modules['builtins'])
    builtins.should_receive('open').with_args('schema.yaml').and_return('')
    flexmock(module.yaml).should_receive('round_trip_load')
    flexmock(module).should_receive('_schema_to_sample_configuration')
    flexmock(module).should_receive(
        'merge_source_configuration_into_destination')
    flexmock(module).should_receive('render_configuration')
    flexmock(module).should_receive('_comment_out_optional_configuration')
    flexmock(module).should_receive('write_configuration')

    module.generate_sample_configuration(None, 'dest.yaml', 'schema.yaml')
Esempio n. 5
0
def main():  # pragma: no cover
    try:
        args = parse_arguments(*sys.argv[1:])

        generate.generate_sample_configuration(args.destination_filename, validate.schema_filename())

        print('Generated a sample configuration file at {}.'.format(args.destination_filename))
        print()
        print('Please edit the file to suit your needs. The values are just representative.')
        print('All fields are optional except where indicated.')
    except (ValueError, OSError) as error:
        print(error, file=sys.stderr)
        sys.exit(1)
Esempio n. 6
0
def main():  # pragma: no cover
    try:
        args = parse_arguments(*sys.argv[1:])

        generate.generate_sample_configuration(args.destination_filename,
                                               validate.schema_filename())

        print('Generated a sample configuration file at {}.'.format(
            args.destination_filename))
        print()
        print(
            'Please edit the file to suit your needs. The values are just representative.'
        )
        print('All fields are optional except where indicated.')
    except (ValueError, OSError) as error:
        print(error, file=sys.stderr)
        sys.exit(1)