<commit_before># Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# 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.

"""
Command-line interface to the monasca-events API.
"""

from __future__ import print_function

import argparse
import logging
import string
import sys

import monasca_events
from monasca_events import client as monasca_client
from monasca_events.common import utils
from monasca_events import exc
from monasca_events import ksclient

EVENTS_API_URL = 'http://192.168.10.4:8082/v2.0/'


logger = logging.getLogger(__name__)


class MonascaShell(object):

    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog='monasca-events',
            description=__doc__.strip(),
            epilog='See "monasca-events help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            # formatter_class=HelpFormatter,
            formatter_class=lambda prog: argparse.HelpFormatter(
                prog,
                max_help_position=29)
        )

        # Global arguments
        parser.add_argument('-h', '--help',
                            action='store_true',
                            help=argparse.SUPPRESS)

        parser.add_argument('-j', '--json',
                            action='store_true',
                            help='output raw json response')

        parser.add_argument('--version',
                            action='version',
                            version=monasca_events.__version__,
                            help="Shows the client version and exits.")

        parser.add_argument('-d', '--debug',
                            default=bool(utils.env('MONASCA_DEBUG')),
                            action='store_true',
                            help='Defaults to env[MONASCA_DEBUG].')

        parser.add_argument('-v', '--verbose',
                            default=False, action="store_true",
                            help="Print more verbose output.")

        parser.add_argument('-k', '--insecure',
                            default=False,
                            action='store_true',
                            help="Explicitly allow the client to perform "
                            "\"insecure\" SSL (https) requests. The server's "
                            "certificate will not be verified against any "
                            "certificate authorities. "
                            "This option should be used with caution.")

        parser.add_argument('--cert-file',
                            help='Path of certificate file to use in SSL '
                            'connection. This file can optionally be '
                            'prepended with the private key.')

        parser.add_argument(
            '--key-file',
            help='Path of client key to use in SSL connection. '
            'This option is not necessary if your key is'
            ' prepended to your cert file.')

        parser.add_argument('--os-cacert',
                            default=utils.env('OS_CACERT'),
                            help='Specify a CA bundle file to use in verifying'
                            ' a TLS (https) server certificate. Defaults to'
                            ' env[OS_CACERT]. Without either of these, the'
                            ' client looks for the default system CA'
                            ' certificates.')

        parser.add_argument('--timeout',
                            default=600,
                            help='Number of seconds to wait for a response.')

        parser.add_argument('--os-username',
                            default=utils.env('OS_USERNAME'),
                            help='Defaults to env[OS_USERNAME].')

        parser.add_argument('--os_username',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-password',
                            default=utils.env('OS_PASSWORD'),
                            help='Defaults to env[OS_PASSWORD].')

        parser.add_argument('--os_password',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-project-id',
                            default=utils.env('OS_PROJECT_ID'),
                            help='Defaults to env[OS_PROJECT_ID].')

        parser.add_argument('--os_project_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-project-name',
                            default=utils.env('OS_PROJECT_NAME'),
                            help='Defaults to env[OS_PROJECT_NAME].')

        parser.add_argument('--os_project_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-domain-id',
                            default=utils.env('OS_DOMAIN_ID'),
                            help='Defaults to env[OS_DOMAIN_ID].')

        parser.add_argument('--os_domain_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-domain-name',
                            default=utils.env('OS_DOMAIN_NAME'),
                            help='Defaults to env[OS_DOMAIN_NAME].')

        parser.add_argument('--os_domain_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-url',
                            default=utils.env('OS_AUTH_URL'),
                            help='Defaults to env[OS_AUTH_URL].')

        parser.add_argument('--os_auth_url',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
                            default=utils.env('OS_REGION_NAME'),
                            help='Defaults to env[OS_REGION_NAME].')

        parser.add_argument('--os_region_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-token',
                            default=utils.env('OS_AUTH_TOKEN'),
                            help='Defaults to env[OS_AUTH_TOKEN].')

        parser.add_argument('--os_auth_token',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-no-client-auth',
                            default=utils.env('OS_NO_CLIENT_AUTH'),
                            action='store_true',
                            help="Do not contact keystone for a token. "
                                 "Defaults to env[OS_NO_CLIENT_AUTH].")

        parser.add_argument('--monasca-api-url',
                            default=EVENTS_API_URL,
                            help='Defaults to EVENTS_API_URL '
                                 'in events_shell.py')<commit_msg>fix events api url env var<commit_after># Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# 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.

"""
Command-line interface to the monasca-events API.
"""

from __future__ import print_function

import argparse
import logging
import string
import sys

import monasca_events
from monasca_events import client as monasca_client
from monasca_events.common import utils
from monasca_events import exc
from monasca_events import ksclient


logger = logging.getLogger(__name__)


class MonascaShell(object):

    def get_base_parser(self):
        parser = argparse.ArgumentParser(
            prog='monasca-events',
            description=__doc__.strip(),
            epilog='See "monasca-events help COMMAND" '
                   'for help on a specific command.',
            add_help=False,
            # formatter_class=HelpFormatter,
            formatter_class=lambda prog: argparse.HelpFormatter(
                prog,
                max_help_position=29)
        )

        # Global arguments
        parser.add_argument('-h', '--help',
                            action='store_true',
                            help=argparse.SUPPRESS)

        parser.add_argument('-j', '--json',
                            action='store_true',
                            help='output raw json response')

        parser.add_argument('--version',
                            action='version',
                            version=monasca_events.__version__,
                            help="Shows the client version and exits.")

        parser.add_argument('-d', '--debug',
                            default=bool(utils.env('MONASCA_DEBUG')),
                            action='store_true',
                            help='Defaults to env[MONASCA_DEBUG].')

        parser.add_argument('-v', '--verbose',
                            default=False, action="store_true",
                            help="Print more verbose output.")

        parser.add_argument('-k', '--insecure',
                            default=False,
                            action='store_true',
                            help="Explicitly allow the client to perform "
                            "\"insecure\" SSL (https) requests. The server's "
                            "certificate will not be verified against any "
                            "certificate authorities. "
                            "This option should be used with caution.")

        parser.add_argument('--cert-file',
                            help='Path of certificate file to use in SSL '
                            'connection. This file can optionally be '
                            'prepended with the private key.')

        parser.add_argument(
            '--key-file',
            help='Path of client key to use in SSL connection. '
            'This option is not necessary if your key is'
            ' prepended to your cert file.')

        parser.add_argument('--os-cacert',
                            default=utils.env('OS_CACERT'),
                            help='Specify a CA bundle file to use in verifying'
                            ' a TLS (https) server certificate. Defaults to'
                            ' env[OS_CACERT]. Without either of these, the'
                            ' client looks for the default system CA'
                            ' certificates.')

        parser.add_argument('--timeout',
                            default=600,
                            help='Number of seconds to wait for a response.')

        parser.add_argument('--os-username',
                            default=utils.env('OS_USERNAME'),
                            help='Defaults to env[OS_USERNAME].')

        parser.add_argument('--os_username',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-password',
                            default=utils.env('OS_PASSWORD'),
                            help='Defaults to env[OS_PASSWORD].')

        parser.add_argument('--os_password',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-project-id',
                            default=utils.env('OS_PROJECT_ID'),
                            help='Defaults to env[OS_PROJECT_ID].')

        parser.add_argument('--os_project_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-project-name',
                            default=utils.env('OS_PROJECT_NAME'),
                            help='Defaults to env[OS_PROJECT_NAME].')

        parser.add_argument('--os_project_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-domain-id',
                            default=utils.env('OS_DOMAIN_ID'),
                            help='Defaults to env[OS_DOMAIN_ID].')

        parser.add_argument('--os_domain_id',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-domain-name',
                            default=utils.env('OS_DOMAIN_NAME'),
                            help='Defaults to env[OS_DOMAIN_NAME].')

        parser.add_argument('--os_domain_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-url',
                            default=utils.env('OS_AUTH_URL'),
                            help='Defaults to env[OS_AUTH_URL].')

        parser.add_argument('--os_auth_url',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-region-name',
                            default=utils.env('OS_REGION_NAME'),
                            help='Defaults to env[OS_REGION_NAME].')

        parser.add_argument('--os_region_name',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-auth-token',
                            default=utils.env('OS_AUTH_TOKEN'),
                            help='Defaults to env[OS_AUTH_TOKEN].')

        parser.add_argument('--os_auth_token',
                            help=argparse.SUPPRESS)

        parser.add_argument('--os-no-client-auth',
                            default=utils.env('OS_NO_CLIENT_AUTH'),
                            action='store_true',
                            help="Do not contact keystone for a token. "
                                 "Defaults to env[OS_NO_CLIENT_AUTH].")

        parser.add_argument('--monasca-api-url',
                            default=utils.env('EVENTS_API_URL'),
                            help='Defaults to env[EVENTS_API_URL]')
{'fraction_non_alphanumeric': 0.09690113133300542, 'fraction_numerical': 0.002881034361604947, 'mean_word_length': 1.4588804422944022, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3197266', 'n_tokens_mistral': 3621, 'n_tokens_neox': 3497, 'n_words': 784}