<commit_before>#!/usr/bin/env python
# Copyright 2015-2018 Yelp Inc.
# 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.
"""
Usage: ./setup_tron_namespace.py service [service...] | --all

Deploy a namespace to the local Tron master from a service configuration file.
Reads from the soa_dir /nail/etc/services by default.

The script will load the service configuration file, generate a Tron configuration
file for it, and send the updated file to Tron.
"""
import argparse
import logging
import sys

from paasta_tools import tron_tools

log = logging.getLogger(__name__)


def parse_args():
    parser = argparse.ArgumentParser(
        description='Update the Tron namespace configuration for a service.',
    )
    parser.add_argument(
        'services',
        nargs='*',
        help='Services to update.',
    )
    parser.add_argument(
        '-a',
        '--all',
        dest='all_namepsaces',
        action='store_true',
        help='Update all available Tron namespaces.',
    )
    parser.add_argument(
        '-d',
        '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=tron_tools.DEFAULT_SOA_DIR,
        help="Use a different soa config directory",
    )
    parser.add_argument(
        '-v',
        '--verbose',
        action='store_true',
        default=False,
    )
    args = parser.parse_args()
    return args


def main():
    args = parse_args()

    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.WARNING)

    if args.all_namespaces:
        try:
            services = tron_tools.get_tron_namespaces_for_cluster()
        except Exception as e:
            log.error('Failed to list tron namespaces: {error}'.format(
                error=str(e),<commit_msg>make --all and service list mutually exclusive<commit_after>#!/usr/bin/env python
# Copyright 2015-2018 Yelp Inc.
# 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.
"""
Usage: ./setup_tron_namespace.py service [service...] | --all

Deploy a namespace to the local Tron master from a service configuration file.
Reads from the soa_dir /nail/etc/services by default.

The script will load the service configuration file, generate a Tron configuration
file for it, and send the updated file to Tron.
"""
import argparse
import logging
import sys

from paasta_tools import tron_tools

log = logging.getLogger(__name__)


def parse_args():
    parser = argparse.ArgumentParser(
        description='Update the Tron namespace configuration for a service.',
    )
    parser.add_argument(
        'services',
        nargs='*',
        help='Services to update.',
    )
    parser.add_argument(
        '-a',
        '--all',
        dest='all_namepsaces',
        action='store_true',
        help='Update all available Tron namespaces.',
    )
    parser.add_argument(
        '-d',
        '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=tron_tools.DEFAULT_SOA_DIR,
        help="Use a different soa config directory",
    )
    parser.add_argument(
        '-v',
        '--verbose',
        action='store_true',
        default=False,
    )
    args = parser.parse_args()
    return args


def main():
    args = parse_args()
    log_level = logging.DEBUG if args.verbose else logging.WARNING
    logging.basicConfig(level=log_level)

    if args.all_namespaces:
        if args.services:
            log.error('Do not pass service names with --all flag')
            sys.exit(1)

        try:
            services = tron_tools.get_tron_namespaces_for_cluster()
        except Exception as e:
            log.error('Failed to list tron namespaces: {error}'.format(
                error=str(e),
{'fraction_non_alphanumeric': 0.09496494582536648, 'fraction_numerical': 0.0053112385808370514, 'mean_word_length': 2.7633892885691447, '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': '2871118', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1301, 'n_words': 452}