Skip to content

Commit d46834f

Browse files
authored
Merge pull request #109 from padovan/minor_improvements
Minor improvements (debug and cmd exit fixes)
2 parents d3cc00e + 5d3e460 commit d46834f

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

kcidev/libs/common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
import logging
45
import os
56
import sys
67

@@ -65,6 +66,10 @@ def config_path(settings):
6566
return global_path
6667

6768

69+
def kci_info(content):
70+
logging.info(content)
71+
72+
6873
def kci_msg(content):
6974
click.echo(content)
7075

kcidev/libs/maestro_common.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
import errno
45
import json
56
import time
67

@@ -11,9 +12,9 @@
1112

1213

1314
def maestro_print_api_call(host, data=None):
14-
click.secho("maestro api endpoint: " + host, fg="green")
15+
kci_info("maestro api endpoint: " + host)
1516
if data:
16-
kci_log(json.dumps(data, indent=4))
17+
kci_info(json.dumps(data, indent=4))
1718

1819

1920
def maestro_api_error(response):
@@ -53,10 +54,10 @@ def maestro_get_node(url, nodeid):
5354
response.raise_for_status()
5455
except requests.exceptions.HTTPError as ex:
5556
kci_err(ex.response.json().get("detail"))
56-
click.Abort()
57+
sys.exit(errno.ENOENT)
5758
except Exception as ex:
5859
kci_err(ex)
59-
click.Abort()
60+
sys.exit(errno.ENOENT)
6061

6162
return response.json()
6263

@@ -78,10 +79,10 @@ def maestro_get_nodes(url, limit, offset, filter):
7879
response.raise_for_status()
7980
except requests.exceptions.HTTPError as ex:
8081
kci_err(ex.response.json().get("detail"))
81-
click.Abort()
82+
sys.exit(errno.ENOENT)
8283
except Exception as ex:
8384
kci_err(ex)
84-
click.Abort()
85+
sys.exit(errno.ENOENT)
8586

8687
return response.json()
8788

kcidev/main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
import logging
5+
46
import click
57

68
from kcidev.libs.common import *
@@ -28,8 +30,14 @@
2830
required=False,
2931
)
3032
@click.option("--instance", help="API instance to use", required=False)
33+
@click.option("--debug", is_flag=True, help="Enable debug info")
3134
@click.pass_context
32-
def cli(ctx, settings, instance):
35+
def cli(ctx, settings, instance, debug):
36+
if debug:
37+
# DEBUG level is too verbose about included packages
38+
# us INFO instead
39+
logging.basicConfig(level=logging.INFO)
40+
3341
subcommand = ctx.invoked_subcommand
3442
ctx.obj = {"CFG": load_toml(settings, subcommand)}
3543
ctx.obj["SETTINGS"] = settings

kcidev/subcommands/checkout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def retrieve_tot_commit(repourl, branch):
5959
return sha
6060

6161

62-
@click.command(help="Create custom tree checkout on KernelCI and trigger a tests")
62+
@click.command(help="Trigger a test for a specific tree/branch/commit")
6363
@click.option(
6464
"--giturl",
6565
help="Git URL to checkout",

0 commit comments

Comments
 (0)