autograder.cli.courses.upsert.filespec

Upsert a course using a file specification (FileSpec).

usage: python3 -m autograder.cli.courses.upsert.filespec [-h] [--version]
                                                         [--server SERVER]
                                                         [--user USER]
                                                         [--pass PASS]
                                                         [--dry-run]
                                                         [--skip-emails]
                                                         [--skip-source-sync]
                                                         [--skip-lms-sync]
                                                         [--skip-build-images]
                                                         [--skip-template-files]
                                                         --type FILESPEC_TYPE
                                                         --path FILESPEC_PATH
                                                         [--reference FILESPEC_REFERENCE]
                                                         [--username FILESPEC_USERNAME]
                                                         [--token FILESPEC_TOKEN]
                                                         [--testing-mode]

Upsert a course using a file specification (FileSpec).

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.
    --dry-run           Do not commit/finalize the operation, just do all the
                        steps and state what the result would look like.
    --skip-emails       Skip sending any emails.
    --skip-source-sync  Skip syncing (updating with) the course source.
    --skip-lms-sync     Skip syncing with the LMS.
    --skip-build-images
                        Skip building assignment Docker images.
    --skip-template-files
                        Skip fetching assignment template files.
    --type FILESPEC_TYPE
                        The type of filespec.
    --path FILESPEC_PATH
                        The path the filespec points to.
    --reference FILESPEC_REFERENCE
                        The reference (e.g., git commit/branch) of the
                        filespec.
    --username FILESPEC_USERNAME
                        The username for filespec authentication.
    --token FILESPEC_TOKEN
                        The token for filespec authentication.

testing options:
    --testing-mode      Run as if a test is being run (default: False).
 1"""
 2Upsert a course using a file specification (FileSpec).
 3"""
 4
 5import argparse
 6import sys
 7import typing
 8
 9import edq.util.json
10
11import autograder.api.courses.upsert.filespec
12import autograder.cli.parser
13import autograder.filespec
14import autograder.model.config
15
16def run_cli(args: argparse.Namespace) -> int:
17    """ Run the CLI. """
18
19    config = args._config_info.application_config
20
21    config.filespec = _build_filespec(config)
22
23    result = autograder.api.courses.upsert.filespec.send(config, exit_on_error = True)
24    print(edq.util.json.dumps(result, indent = 4))
25
26    return 0
27
28def _build_filespec(config: autograder.model.config.Config) -> autograder.filespec.FileSpec:
29    data: typing.Dict[str, str] = {
30        'type': str(config.filespec_type),
31        'path': str(config.filespec_path),
32    }
33
34    for base_key in ['reference', 'username', 'token']:
35        value = getattr(config, f"filespec_{base_key}", None)
36        if (value is None):
37            continue
38
39        data[base_key] = value
40
41    return autograder.filespec.parse(data)
42
43def main() -> int:
44    """ Get a parser, parse the args, and call run. """
45
46    return run_cli(_get_parser().parse_args())
47
48def _get_parser() -> argparse.ArgumentParser:
49    """ Get a parser for this operation. """
50
51    parser = autograder.cli.parser.get_parser(
52        __doc__.strip(),
53        autograder.api.courses.upsert.filespec.API_PARAMS)
54
55    return parser
56
57if (__name__ == '__main__'):
58    sys.exit(main())
def run_cli(args: argparse.Namespace) -> int:
17def run_cli(args: argparse.Namespace) -> int:
18    """ Run the CLI. """
19
20    config = args._config_info.application_config
21
22    config.filespec = _build_filespec(config)
23
24    result = autograder.api.courses.upsert.filespec.send(config, exit_on_error = True)
25    print(edq.util.json.dumps(result, indent = 4))
26
27    return 0

Run the CLI.

def main() -> int:
44def main() -> int:
45    """ Get a parser, parse the args, and call run. """
46
47    return run_cli(_get_parser().parse_args())

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