<commit_before>########
# Copyright (c) 2014 GigaSpaces Technologies Ltd. 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 six import exec_
from fabric import api as fabric_api

from cloudify.decorators import operation
from cloudify.exceptions import NonRecoverableError
from cloudify import ctx

from fabric_plugin import exec_env

FABRIC_ENV_DEFAULTS = {
    'warn_only': False,
    'connection_attempts': 5,
    'timeout': 10,
    'forward_agent': True,
    'abort_on_prompts': True,
    'keepalive': 0,
    'linewise': False,
    'pool_size': 0,
    'skip_bad_hosts': False,
    'status': False,
    'disable_known_hosts': False,
    'combine_stderr': False,
}


@operation
def run_task(tasks_file, task_name, fabric_env, **kwargs):
    """runs the specified fabric task loaded from 'tasks_file'

    :param tasks_file: the tasks file
    :param task_name: the task name to run in 'tasks_file'
    :param fabric_env: fabric configuration
    """
    task = _get_task(ctx, tasks_file, task_name)
    ctx.logger.info('running task: {0} from {1}'.format(task_name, tasks_file))
    with fabric_api.settings(**_fabric_env(ctx, fabric_env)):
        task(ctx)


@operation
def run_commands(commands, fabric_env, **kwargs):
    """runs the provider 'commands' in sequence

    :param commands: a list of commands to run
    :param fabric_env: fabric configuration<commit_msg>CFY-1295 update default<commit_after>########
# Copyright (c) 2014 GigaSpaces Technologies Ltd. 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 six import exec_
from fabric import api as fabric_api

from cloudify.decorators import operation
from cloudify.exceptions import NonRecoverableError
from cloudify import ctx

from fabric_plugin import exec_env

FABRIC_ENV_DEFAULTS = {
    'warn_only': False,
    'connection_attempts': 5,
    'timeout': 10,
    'forward_agent': True,
    'abort_on_prompts': True,
    'keepalive': 0,
    'linewise': False,
    'pool_size': 0,
    'skip_bad_hosts': False,
    'status': False,
    'disable_known_hosts': False,
    'combine_stderr': True,
}


@operation
def run_task(tasks_file, task_name, fabric_env, **kwargs):
    """runs the specified fabric task loaded from 'tasks_file'

    :param tasks_file: the tasks file
    :param task_name: the task name to run in 'tasks_file'
    :param fabric_env: fabric configuration
    """
    task = _get_task(ctx, tasks_file, task_name)
    ctx.logger.info('running task: {0} from {1}'.format(task_name, tasks_file))
    with fabric_api.settings(**_fabric_env(ctx, fabric_env)):
        task(ctx)


@operation
def run_commands(commands, fabric_env, **kwargs):
    """runs the provider 'commands' in sequence

    :param commands: a list of commands to run
    :param fabric_env: fabric configuration
{'fraction_non_alphanumeric': 0.09398594116115595, 'fraction_numerical': 0.008851861494402499, 'mean_word_length': 4.10904255319149, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2448827', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1128, 'n_words': 417}