Skip to content

Commit

Permalink
Merge pull request #20 from aliceinwire/pytest_update
Browse files Browse the repository at this point in the history
kci-dev/results: Get results list
  • Loading branch information
aliceinwire authored Oct 3, 2024
2 parents 14efa29 + 5679060 commit e21a20a
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions kci-dev/subcommands/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,46 @@ def get_node(url, nodeid):
click.secho(url)
response = requests.get(url, headers=headers)
click.secho(response.status_code, fg="green")
click.secho(pprint.pprint(response.json()), fg="green")
try:
click.secho(pprint.pprint(response.json()), fg="green")
except:
click.secho(pprint.pprint(response.text), fg="green")


def get_nodes(url):
headers = {
"Content-Type": "application/json; charset=utf-8",
}
url = url + "/nodes"
click.secho(url)
response = requests.get(url, headers=headers)
click.secho(response.status_code, fg="green")
try:
click.secho(pprint.pprint(response.json()), fg="green")
except:
click.secho(pprint.pprint(response.text), fg="green")


@click.command(help="Get results")
@click.option(
"--nodeid",
required=True,
required=False,
help="select node_id",
)
@click.option(
"--nodes",
required=False,
help="Get last nodes results",
)
@click.pass_context
def results(ctx, nodeid):
def results(ctx, nodeid, nodes):
config = ctx.obj.get("CFG")
instance = ctx.obj.get("INSTANCE")
url = api_connection(config[instance]["host"])
get_node(url, nodeid)
if nodeid:
get_node(url, nodeid)
if nodes:
get_nodes(url)


if __name__ == "__main__":
Expand Down

0 comments on commit e21a20a

Please sign in to comment.