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
23 changes: 11 additions & 12 deletions kernelci/cli/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

"""Tool to interact with the Pub/Sub interface and message queues"""

import sys
import json

import click
Expand Down Expand Up @@ -47,16 +46,16 @@ def unsubscribe(config, api, sub_id, secrets):


@kci_event.command(secrets=True)
@click.argument('input_file', type=click.File('r'))
@click.option('--is-json', help="Parse input data as JSON", is_flag=True)
@Args.config
@Args.api
@click.argument('channel')
def send(config, api, is_json, channel, secrets):
"""Read some data on stdin and send it as an event on a channel"""
# pylint: disable=too-many-arguments
def send(input_file, is_json, config, api, channel, secrets):
"""Read some data and send it as an event on a channel"""
api = get_api(config, api, secrets)
data = sys.stdin.read()
if is_json:
data = json.loads(data)
data = json.load(input_file) if is_json else input_file.read()
api.send_event(channel, {'data': data})


Expand All @@ -78,16 +77,16 @@ def receive(config, api, indent, sub_id, secrets):


@kci_event.command(secrets=True)
@click.argument('input_file', type=click.File('r'))
@click.argument('list_name')
@click.option('--is-json', help="Parse input data as JSON", is_flag=True)
@Args.config
@Args.api
@click.argument('list_name')
def push(config, api, is_json, list_name, secrets):
"""Read some data on stdin and push it as an event on a list"""
# pylint: disable=too-many-arguments
def push(input_file, list_name, is_json, config, api, secrets):
"""Read some data and push it as an event on a list"""
api = get_api(config, api, secrets)
data = sys.stdin.read()
if is_json:
data = json.loads(data)
data = json.load(input_file) if is_json else input_file.read()
api.push_event(list_name, {'data': data})


Expand Down
8 changes: 4 additions & 4 deletions kernelci/cli/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""Tool to manage KernelCI API node objects"""

import json
import sys

import click

Expand Down Expand Up @@ -69,13 +68,14 @@ def count(attributes, config, api):


@kci_node.command(secrets=True)
@click.argument('input_file', type=click.File('r'))
@Args.config
@Args.api
@Args.indent
def submit(config, api, secrets, indent):
"""Submit a new node or update an existing one from stdin"""
def submit(input_file, config, api, indent, secrets):
"""Submit a new node or update an existing one"""
api = get_api(config, api, secrets)
data = json.load(sys.stdin)
data = json.load(input_file)
if 'id' in data:
node = api.update_node(data)
else:
Expand Down