Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions kcidev/libs/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
DASHBOARD_API = "https://dashboard.kernelci.org/api/"


def dashboard_api_fetch(endpoint, params, max_retries=3):
def dashboard_api_fetch(endpoint, params, use_json, max_retries=3):
base_url = urllib.parse.urljoin(DASHBOARD_API, endpoint)
url = "{}?{}".format(base_url, urllib.parse.urlencode(params))
retries = 0
Expand All @@ -31,7 +31,10 @@ def dashboard_api_fetch(endpoint, params, max_retries=3):

data = r.json()
if "error" in data:
kci_msg("json error: " + str(data["error"]))
if use_json:
kci_msg(data)
else:
kci_msg("json error: " + str(data["error"]))
raise click.Abort()
return data

Expand All @@ -43,7 +46,7 @@ def dashboard_api_fetch(endpoint, params, max_retries=3):
raise click.Abort()


def dashboard_fetch_summary(origin, giturl, branch, commit, arch):
def dashboard_fetch_summary(origin, giturl, branch, commit, arch, use_json):
endpoint = f"tree/{commit}/summary"
params = {
"origin": origin,
Expand All @@ -52,10 +55,10 @@ def dashboard_fetch_summary(origin, giturl, branch, commit, arch):
}
if arch is not None:
params["filter_architecture"] = arch
return dashboard_api_fetch(endpoint, params)
return dashboard_api_fetch(endpoint, params, use_json)


def dashboard_fetch_builds(origin, giturl, branch, commit, arch):
def dashboard_fetch_builds(origin, giturl, branch, commit, arch, use_json):
endpoint = f"tree/{commit}/builds"
params = {
"origin": origin,
Expand All @@ -64,10 +67,10 @@ def dashboard_fetch_builds(origin, giturl, branch, commit, arch):
}
if arch is not None:
params["filter_architecture"] = arch
return dashboard_api_fetch(endpoint, params)
return dashboard_api_fetch(endpoint, params, use_json)


def dashboard_fetch_boots(origin, giturl, branch, commit, arch):
def dashboard_fetch_boots(origin, giturl, branch, commit, arch, use_json):
endpoint = f"tree/{commit}/boots"
params = {
"origin": origin,
Expand All @@ -76,10 +79,10 @@ def dashboard_fetch_boots(origin, giturl, branch, commit, arch):
}
if arch is not None:
params["filter_architecture"] = arch
return dashboard_api_fetch(endpoint, params)
return dashboard_api_fetch(endpoint, params, use_json)


def dashboard_fetch_tests(origin, giturl, branch, commit, arch):
def dashboard_fetch_tests(origin, giturl, branch, commit, arch, use_json):
endpoint = f"tree/{commit}/tests"
params = {
"origin": origin,
Expand All @@ -88,16 +91,16 @@ def dashboard_fetch_tests(origin, giturl, branch, commit, arch):
}
if arch is not None:
params["filter_architecture"] = arch
return dashboard_api_fetch(endpoint, params)
return dashboard_api_fetch(endpoint, params, use_json)


def dashboard_fetch_test(test_id):
def dashboard_fetch_test(test_id, use_json):
endpoint = f"test/{test_id}"
return dashboard_api_fetch(endpoint, {})
return dashboard_api_fetch(endpoint, {}, use_json)


def dashboard_fetch_tree_list(origin):
def dashboard_fetch_tree_list(origin, use_json):
params = {
"origin": origin,
}
return dashboard_api_fetch("tree-fast", params)
return dashboard_api_fetch("tree-fast", params, use_json)
2 changes: 1 addition & 1 deletion kcidev/libs/git_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_folder_repository(git_folder, branch):


def get_latest_commit(origin, giturl, branch):
trees = dashboard_fetch_tree_list(origin)
trees = dashboard_fetch_tree_list(origin, False)
for t in trees:
if t["git_repository_url"] == giturl and t["git_repository_branch"] == branch:
return t["git_commit_hash"]
Expand Down
10 changes: 5 additions & 5 deletions kcidev/subcommands/results/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def summary(origin, git_folder, giturl, branch, commit, latest, arch, use_json):
giturl, branch, commit = set_giturl_branch_commit(
origin, giturl, branch, commit, latest, git_folder
)
data = dashboard_fetch_summary(origin, giturl, branch, commit, arch)
data = dashboard_fetch_summary(origin, giturl, branch, commit, arch, use_json)
cmd_summary(data, use_json)


Expand Down Expand Up @@ -161,7 +161,7 @@ def builds(
giturl, branch, commit = set_giturl_branch_commit(
origin, giturl, branch, commit, latest, git_folder
)
data = dashboard_fetch_builds(origin, giturl, branch, commit, arch)
data = dashboard_fetch_builds(origin, giturl, branch, commit, arch, use_json)
cmd_builds(data, commit, download_logs, status, count, use_json)


Expand All @@ -186,7 +186,7 @@ def boots(
giturl, branch, commit = set_giturl_branch_commit(
origin, giturl, branch, commit, latest, git_folder
)
data = dashboard_fetch_boots(origin, giturl, branch, commit, arch)
data = dashboard_fetch_boots(origin, giturl, branch, commit, arch, use_json)
cmd_tests(data["boots"], commit, download_logs, status, filter, count, use_json)


Expand All @@ -211,15 +211,15 @@ def tests(
giturl, branch, commit = set_giturl_branch_commit(
origin, giturl, branch, commit, latest, git_folder
)
data = dashboard_fetch_tests(origin, giturl, branch, commit, arch)
data = dashboard_fetch_tests(origin, giturl, branch, commit, arch, use_json)
cmd_tests(data["tests"], commit, download_logs, status, filter, count, use_json)


@results.command()
@single_build_and_test_options
@results_display_options
def test(op_id, download_logs, use_json):
data = dashboard_fetch_test(op_id)
data = dashboard_fetch_test(op_id, use_json)
cmd_single_test(data, download_logs, use_json)


Expand Down