<commit_before># Copyright 2015 <NAME> (jared at blacknode dot net)
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

from __future__ import print_function
import logging

from mercury.agent.capabilities import capability
from mercury.common.helpers.cli import run


log = logging.getLogger(__name__)


@capability('echo', 'Echo something to the console', num_args=1)
def echo(message):
    """
    Echo the dolphin
    :param message: message to Echo
    :return: None
    """
    log.info('Echo: %s' % message)
    return message


@capability('run', 'Run an arbitrary command', num_args=1)
def runner(command, _input=''):
    """
    Run a shell command
    :param command: The shell command to use
    :param _input: Optional data to pass to stdin
    :return:
    """
    log.info('Running: %s' % command)

    r = run(command, ignore_error=True, raise_exception=False, _input=_input)
    return {
        'stdout': r.stdout,
        'stderr': r.stderr,
        'returncode': r.returncode
    }<commit_msg>squash | adding kexec, maybe<commit_after># Copyright 2015 <NAME> (jared at blacknode dot net)
# All Rights Reserved.
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

from __future__ import print_function
import logging

from mercury.agent.capabilities import capability
from mercury.common.helpers.cli import run


log = logging.getLogger(__name__)


@capability('echo', 'Echo something to the console', num_args=1)
def echo(message):
    """
    Echo the dolphin
    :param message: message to Echo
    :return: None
    """
    log.info('Echo: %s' % message)
    print(message)
    return message


@capability('run', 'Run an arbitrary command', num_args=1)
def runner(command, _input=''):
    """
    Run a shell command
    :param command: The shell command to use
    :param _input: Optional data to pass to stdin
    :return:
    """
    log.info('Running: %s' % command)

    r = run(command, ignore_error=True, raise_exception=False, _input=_input)
    return {
        'stdout': r.stdout,
        'stderr': r.stderr,
        'returncode': r.returncode
    }


@capability('kexec', 'kexec into kernel at supplied location', kwarg_names=['kernel', 'initrd', 'options'])
def kexec(kernel='', initrd='', options=None, kernel_type='bzImage'):
    """
    Kexec into a kernel
    """

{'fraction_non_alphanumeric': 0.10157410157410157, 'fraction_numerical': 0.00594000594000594, 'mean_word_length': 3.514745308310992, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4549362', 'n_tokens_mistral': 987, 'n_tokens_neox': 970, 'n_words': 371}