#!/usr/bin/env python

"""
esmond-ps-get - client to fetch perfsonar test results.
"""

# for the script name:
# pylint: disable=invalid-name

from esmond_client.perfsonar.query import ApiConnect
from esmond_client.perfsonar.util import (
    data_format_factory,
    output_factory,
    perfsonar_client_filters,
    perfsonar_client_opts,
)


def main():
    """main loop/execute query."""
    options, _ = perfsonar_client_opts(require_src_dest=True, require_event=True)

    filters = perfsonar_client_filters(options)
    conn = ApiConnect(options.url, filters)

    header, data = data_format_factory(options)(conn)

    output = output_factory(options, data, header)
    print output.get_output()

if __name__ == '__main__':
    main()
