Exemplo n.º 1
0
def main(args=None, namespace=None):
    args = parse_args(args, namespace)

    # Dynamically set the default output to stdout if it is being piped.
    if args['output'] is None:
        if sys.stdout.isatty():
            args['output'] = './exodus-{{executables}}-bundle.{{extension}}'
        else:
            args['output'] = '-'

    # Handle the CLI specific options here, removing them from `args` in the process.
    quiet, verbose = args.pop('quiet'), args.pop('verbose')
    suppress_stdout = args['output'] == '-'
    configure_logging(quiet=quiet, verbose=verbose, suppress_stdout=suppress_stdout)

    # Allow piping in additional files.
    if not sys.stdin.isatty():
        args['add'] += extract_paths(sys.stdin.read())

    # Create the bundle with all of the arguments.
    try:
        create_bundle(**args)
    except FatalError as fatal_error:
        logger.error('Fatal error encountered, exiting.')
        logger.error(fatal_error, exc_info=verbose)
        sys.exit(1)
Exemplo n.º 2
0
def test_extract_raw_paths():
    input_paths = [
        '/absolute/path/to/file',
        './relative/path',
        '/another/absolute/path',
    ]
    input_paths_with_whitespace = \
        ['  ', ''] + [input_paths[0]] + [' '] + input_paths[1:]
    input_content = '\n'.join(input_paths_with_whitespace)
    extracted_paths = extract_paths(input_content)
    assert set(input_paths) == set(extracted_paths), \
        'The paths should have been extracted without the whitespace.'
Exemplo n.º 3
0
def test_extract_strace_paths():
    with open(exodus_strace, 'r') as f:
        content = f.read()
    extracted_paths = extract_paths(content, existing_only=False)
    expected_paths = [
        # `execve()` call
        '/home/sangaline/projects/exodus/.env/bin/exodus',
        # `openat()` call
        '/usr/lib/libpthread.so.0',
        # `open()` call
        '/usr/lib/gconv/gconv-modules',
    ]

    for path in expected_paths:
        assert path in extracted_paths, \
            '"%s" should be present in the extracted paths.' % path
Exemplo n.º 4
0
def test_extract_no_paths():
    input_paths = extract_paths('')
    assert input_paths == [], 'It should return an empty list.'