autograder.cli.logs.query

Query log entries from the autograder server.

usage: python3 -m autograder.cli.logs.query [-h] [--version] [--server SERVER]
                                            [--user USER] [--pass PASS]
                                            [--level {TRACE,DEBUG,INFO,WARN,ERROR,FATAL,OFF}]
                                            [--after QUERY_AFTER]
                                            [--past QUERY_PAST]
                                            [--target-course QUERY_TARGET_COURSE]
                                            [--target-assignment QUERY_TARGET_ASSIGNMENT]
                                            [--target-email QUERY_TARGET_EMAIL]
                                            [--testing-mode]
                                            [--format {json,table,text}]
                                            [--include-extra-fields]
                                            [--pretty-headers]
                                            [--skip-headers]

Query log entries from the autograder server.

options:
    -h, --help          show this help message and exit
    --version           show program's version number and exit

command-specific options:
    --server SERVER     The URL of the autograder server to communicate with.
    --user USER         The email of the user making this request.
    --pass PASS         The password of the user making this request.
    --level {TRACE,DEBUG,INFO,WARN,ERROR,FATAL,OFF}
                        The minimum level of log records to return. (default:
                        INFO)
    --after QUERY_AFTER
                        If supplied, only return records after this timestamp.
                        (default: None)
    --past QUERY_PAST   If supplied, only return log records in this duration
                        (using "h", "m", or "s" suffixes) (e.g., "24h", "10m",
                        or "1h10m10s"). (default: None)
    --target-course QUERY_TARGET_COURSE
                        If supplied, only return records for this course.
    --target-assignment QUERY_TARGET_ASSIGNMENT
                        If supplied, only return records for this assignment.
    --target-email QUERY_TARGET_EMAIL
                        If supplied, only return records for this user.

testing options:
    --testing-mode      Run as if a test is being run (default: False).

output formatting options:
    --format {json,table,text}
                        The format to display the output as (default: text).
    --include-extra-fields
                        Include uncommon fields in results (default: False).
    --pretty-headers    When displaying headers, try to make them look
                        "pretty" (default: False).
    --skip-headers      Skip headers when outputting results, will not apply
                        to all formats (default: False).
 1"""
 2Query log entries from the autograder server.
 3"""
 4
 5import argparse
 6import sys
 7
 8import lms.model.base
 9
10import autograder.api.logs.query
11import autograder.cli.parser
12
13def run_cli(args: argparse.Namespace) -> int:
14    """ Run the CLI. """
15
16    config = args._config_info.application_config
17
18    error, logs = autograder.api.logs.query.send(config, exit_on_error = True)
19
20    if (error is not None):
21        print(f"Log Query Error -- {error}", file = sys.stderr)
22        return 10
23
24    output = lms.model.base.base_list_to_output_format(logs, config.output_format,
25            skip_headers = args.skip_headers,
26            pretty_headers = args.pretty_headers,
27            include_extra_fields = args.include_extra_fields,
28    )
29    print(output)
30
31    return 0
32
33def main() -> int:
34    """ Get a parser, parse the args, and call run. """
35
36    return run_cli(_get_parser().parse_args())
37
38def _get_parser() -> argparse.ArgumentParser:
39    """ Get a parser for this operation. """
40
41    parser = autograder.cli.parser.get_parser(
42        __doc__.strip(),
43        autograder.api.logs.query.API_PARAMS,
44        include_output_format = True,
45    )
46
47    return parser
48
49if (__name__ == '__main__'):
50    sys.exit(main())
def run_cli(args: argparse.Namespace) -> int:
14def run_cli(args: argparse.Namespace) -> int:
15    """ Run the CLI. """
16
17    config = args._config_info.application_config
18
19    error, logs = autograder.api.logs.query.send(config, exit_on_error = True)
20
21    if (error is not None):
22        print(f"Log Query Error -- {error}", file = sys.stderr)
23        return 10
24
25    output = lms.model.base.base_list_to_output_format(logs, config.output_format,
26            skip_headers = args.skip_headers,
27            pretty_headers = args.pretty_headers,
28            include_extra_fields = args.include_extra_fields,
29    )
30    print(output)
31
32    return 0

Run the CLI.

def main() -> int:
34def main() -> int:
35    """ Get a parser, parse the args, and call run. """
36
37    return run_cli(_get_parser().parse_args())

Get a parser, parse the args, and call run.