forked from kernelci/kci-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
executable file
·74 lines (64 loc) · 2.05 KB
/
Copy pathmain.py
File metadata and controls
executable file
·74 lines (64 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
import click
from kcidev.libs.common import *
from kcidev.subcommands import (
bisect,
checkout,
commit,
config,
maestro,
results,
storage,
submit,
testretry,
watch,
)
@click.group(
help="Stand alone tool for Linux Kernel developers and maintainers to interact with KernelCI."
)
@click.version_option(kcidev_version, prog_name="kci-dev")
@click.option(
"--settings",
default=".kci-dev.toml",
help="Local settings file to use",
required=False,
)
@click.option("--instance", help="API instance to use", required=False)
@click.option("--debug", is_flag=True, help="Enable debug info")
@click.pass_context
def cli(ctx, settings, instance, debug):
if debug:
# DEBUG level is too verbose about included packages
# us INFO instead
logging.basicConfig(level=logging.INFO)
subcommand = ctx.invoked_subcommand
ctx.obj = {"CFG": load_toml(settings, subcommand)}
ctx.obj["SETTINGS"] = settings
if subcommand not in ("results", "config"):
if instance:
ctx.obj["INSTANCE"] = instance
elif subcommand not in ("submit", "storage"):
ctx.obj["INSTANCE"] = ctx.obj["CFG"].get("default_instance")
fconfig = config_path(settings)
if not ctx.obj["INSTANCE"]:
kci_err(f"No instance defined in settings or as argument in {fconfig}")
raise click.Abort()
if ctx.obj["INSTANCE"] not in ctx.obj["CFG"]:
kci_err(f"Instance {ctx.obj['INSTANCE']} not found in {fconfig}")
raise click.Abort()
def run():
cli.add_command(bisect.bisect)
cli.add_command(checkout.checkout)
cli.add_command(commit.commit)
cli.add_command(config.config)
cli.add_command(maestro.maestro)
cli.add_command(testretry.testretry)
cli.add_command(results.results)
cli.add_command(storage.storage)
cli.add_command(submit.submit)
cli.add_command(watch.watch)
cli()
if __name__ == "__main__":
run()