#!python

import os
import argparse
import subprocess

if __name__ == '__main__':
    print('running {}'.format(os.path.basename(__file__)))
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "directory", help="The directory containing the Dockerfile.")
    parser.add_argument(
        "--no-cache", action='store_true',
        help="Disables the cache when building the attack image.")
    parser.add_argument(
        "--gpu", type=int, default=0, help="GPU number to run container on")
    parser.add_argument(
        "--samples", type=int, default=100,
        help="Number of samples for testing.")
    args = parser.parse_args()
    if args.no_cache:
        cache = ' --no-cache'
    else:
        cache = ''
    cmd = ('avc-test-attack{cache} --gpu {gpu} --mode targeted'
           ' --samples {samples} {directory}')
    cmd = cmd.format(
        cache=cache,
        gpu=args.gpu,
        directory=args.directory,
        samples=args.samples)
    subprocess.Popen(cmd, shell=True).wait()
