

def run_backfill(config_path, config_id, config, start_at, end_at):
    collector_path = join(dirname(sys.executable), 'pp-collector')
    query_path = get_query_path(config_path, config_id)
    credentials_path = join(config_path, 'credentials', 'ga.json')
    token_path = get_token_path(config_path, config['token'])
    platform_path = join(config_path, 'performanceplatform.json')
    command = [collector_path, '-q', query_path, '-c', credentials_path, '-t', token_path, '-b', platform_path, '-s', start_at.isoformat()]
    if (end_at is not None):
        command += ['-e', end_at.isoformat()]
    status = subprocess.call(command, stderr=sys.stdout.fileno(), stdout=sys.stdout.fileno())
    if (status != 0):
        print('Failed!')
        raise SystemExit(1)

dataset/ETHPy150Open alphagov/performanceplatform-collector/tools/one-off/recollect.py run_backfill/original