summaryrefslogtreecommitdiff
path: root/osprofiler/cmd
diff options
context:
space:
mode:
authorBoris Pavlovic <boris@pavlovic.me>2015-11-23 01:42:00 -0800
committerBoris Pavlovic <boris@pavlovic.me>2015-11-23 01:42:00 -0800
commit435e6a6fc3e32e82448b0359df15e99fb15d680f (patch)
tree75ebc2e4df6b2915aaa59355780bb944c9d75b0f /osprofiler/cmd
parentcabf79d44c77a9259481cabfa888e99730fb40b0 (diff)
downloadosprofiler-435e6a6fc3e32e82448b0359df15e99fb15d680f.tar.gz
Add hacking rules & fix hacking issues
Change-Id: Id335bfdf49ed88edd14e896a48c22b11113600c8
Diffstat (limited to 'osprofiler/cmd')
-rw-r--r--osprofiler/cmd/cliutils.py4
-rw-r--r--osprofiler/cmd/commands.py16
-rw-r--r--osprofiler/cmd/shell.py190
3 files changed, 105 insertions, 105 deletions
diff --git a/osprofiler/cmd/cliutils.py b/osprofiler/cmd/cliutils.py
index ded95bd..bcd413b 100644
--- a/osprofiler/cmd/cliutils.py
+++ b/osprofiler/cmd/cliutils.py
@@ -25,7 +25,7 @@ def env(*args, **kwargs):
value = os.environ.get(arg)
if value:
return value
- return kwargs.get('default', '')
+ return kwargs.get("default", "")
def arg(*args, **kwargs):
@@ -46,7 +46,7 @@ def arg(*args, **kwargs):
def add_arg(func, *args, **kwargs):
"""Bind CLI arguments to a shell.py `do_foo` function."""
- if not hasattr(func, 'arguments'):
+ if not hasattr(func, "arguments"):
func.arguments = []
# NOTE(sirp): avoid dups that can occur when the module is shared across
diff --git a/osprofiler/cmd/commands.py b/osprofiler/cmd/commands.py
index 03be461..d801bab 100644
--- a/osprofiler/cmd/commands.py
+++ b/osprofiler/cmd/commands.py
@@ -28,12 +28,12 @@ class BaseCommand(object):
class TraceCommands(BaseCommand):
group_name = "trace"
- @cliutils.arg('trace_id', help='trace id')
- @cliutils.arg('--json', dest='use_json', action='store_true',
- help='show trace in JSON')
- @cliutils.arg('--html', dest='use_html', action='store_true',
- help='show trace in HTML')
- @cliutils.arg('--out', dest='file_name', help='save output in file')
+ @cliutils.arg("trace_id", help="trace id")
+ @cliutils.arg("--json", dest="use_json", action="store_true",
+ help="show trace in JSON")
+ @cliutils.arg("--html", dest="use_html", action="store_true",
+ help="show trace in HTML")
+ @cliutils.arg("--out", dest="file_name", help="save output in file")
def show(self, args):
"""Displays trace-results by given trace id in HTML or JSON format."""
try:
@@ -50,7 +50,7 @@ class TraceCommands(BaseCommand):
notifications = ceiloparser.get_notifications(
client, args.trace_id)
except Exception as e:
- if hasattr(e, 'http_status') and e.http_status == 401:
+ if hasattr(e, "http_status") and e.http_status == 401:
msg = "Invalid OpenStack Identity credentials."
else:
msg = "Something has gone wrong. See logs for more details."
@@ -80,7 +80,7 @@ class TraceCommands(BaseCommand):
"output-formats: --json or --html.")
if args.file_name:
- with open(args.file_name, 'w+') as output_file:
+ with open(args.file_name, "w+") as output_file:
output_file.write(output)
else:
print (output)
diff --git a/osprofiler/cmd/shell.py b/osprofiler/cmd/shell.py
index c7113c8..e613a90 100644
--- a/osprofiler/cmd/shell.py
+++ b/osprofiler/cmd/shell.py
@@ -68,8 +68,8 @@ class OSProfilerShell(object):
add_help=True
)
- parser.add_argument('-v', '--version',
- action='version',
+ parser.add_argument("-v", "--version",
+ action="version",
version=osprofiler.__version__)
self._append_ceilometer_args(parser)
@@ -79,24 +79,24 @@ class OSProfilerShell(object):
return parser
def _append_ceilometer_args(self, parent_parser):
- parser = parent_parser.add_argument_group('ceilometer')
+ parser = parent_parser.add_argument_group("ceilometer")
parser.add_argument(
- '--ceilometer-url', default=cliutils.env('CEILOMETER_URL'),
- help='Defaults to env[CEILOMETER_URL].')
+ "--ceilometer-url", default=cliutils.env("CEILOMETER_URL"),
+ help="Defaults to env[CEILOMETER_URL].")
parser.add_argument(
- '--ceilometer-api-version',
- default=cliutils.env('CEILOMETER_API_VERSION', default='2'),
- help='Defaults to env[CEILOMETER_API_VERSION] or 2.')
+ "--ceilometer-api-version",
+ default=cliutils.env("CEILOMETER_API_VERSION", default="2"),
+ help="Defaults to env[CEILOMETER_API_VERSION] or 2.")
def _append_identity_args(self, parent_parser):
# FIXME(fabgia): identity related parameters should be passed by the
# Keystone client itself to avoid constant update in all the services
# clients. When this fix is merged this method can be made obsolete.
# Bug: https://bugs.launchpad.net/python-keystoneclient/+bug/1332337
- parser = parent_parser.add_argument_group('identity')
- parser.add_argument('-k', '--insecure',
+ parser = parent_parser.add_argument_group("identity")
+ parser.add_argument("-k", "--insecure",
default=False,
- action='store_true',
+ action="store_true",
help="Explicitly allow osprofiler to "
"perform \"insecure\" SSL (https) requests. "
"The server's certificate will "
@@ -105,113 +105,113 @@ class OSProfilerShell(object):
"caution.")
# User related options
- parser.add_argument('--os-username',
- default=cliutils.env('OS_USERNAME'),
- help='Defaults to env[OS_USERNAME].')
+ parser.add_argument("--os-username",
+ default=cliutils.env("OS_USERNAME"),
+ help="Defaults to env[OS_USERNAME].")
- parser.add_argument('--os-user-id',
- default=cliutils.env('OS_USER_ID'),
- help='Defaults to env[OS_USER_ID].')
+ parser.add_argument("--os-user-id",
+ default=cliutils.env("OS_USER_ID"),
+ help="Defaults to env[OS_USER_ID].")
- parser.add_argument('--os-password',
- default=cliutils.env('OS_PASSWORD'),
- help='Defaults to env[OS_PASSWORD].')
+ parser.add_argument("--os-password",
+ default=cliutils.env("OS_PASSWORD"),
+ help="Defaults to env[OS_PASSWORD].")
# Domain related options
- parser.add_argument('--os-user-domain-id',
- default=cliutils.env('OS_USER_DOMAIN_ID'),
- help='Defaults to env[OS_USER_DOMAIN_ID].')
+ parser.add_argument("--os-user-domain-id",
+ default=cliutils.env("OS_USER_DOMAIN_ID"),
+ help="Defaults to env[OS_USER_DOMAIN_ID].")
- parser.add_argument('--os-user-domain-name',
- default=cliutils.env('OS_USER_DOMAIN_NAME'),
- help='Defaults to env[OS_USER_DOMAIN_NAME].')
+ parser.add_argument("--os-user-domain-name",
+ default=cliutils.env("OS_USER_DOMAIN_NAME"),
+ help="Defaults to env[OS_USER_DOMAIN_NAME].")
- parser.add_argument('--os-project-domain-id',
- default=cliutils.env('OS_PROJECT_DOMAIN_ID'),
- help='Defaults to env[OS_PROJECT_DOMAIN_ID].')
+ parser.add_argument("--os-project-domain-id",
+ default=cliutils.env("OS_PROJECT_DOMAIN_ID"),
+ help="Defaults to env[OS_PROJECT_DOMAIN_ID].")
- parser.add_argument('--os-project-domain-name',
- default=cliutils.env('OS_PROJECT_DOMAIN_NAME'),
- help='Defaults to env[OS_PROJECT_DOMAIN_NAME].')
+ parser.add_argument("--os-project-domain-name",
+ default=cliutils.env("OS_PROJECT_DOMAIN_NAME"),
+ help="Defaults to env[OS_PROJECT_DOMAIN_NAME].")
# Project V3 or Tenant V2 related options
- parser.add_argument('--os-project-id',
- default=cliutils.env('OS_PROJECT_ID'),
- help='Another way to specify tenant ID. '
- 'This option is mutually exclusive with '
- ' --os-tenant-id. '
- 'Defaults to env[OS_PROJECT_ID].')
-
- parser.add_argument('--os-project-name',
- default=cliutils.env('OS_PROJECT_NAME'),
- help='Another way to specify tenant name. '
- 'This option is mutually exclusive with '
- ' --os-tenant-name. '
- 'Defaults to env[OS_PROJECT_NAME].')
-
- parser.add_argument('--os-tenant-id',
- default=cliutils.env('OS_TENANT_ID'),
- help='This option is mutually exclusive with '
- ' --os-project-id. '
- 'Defaults to env[OS_PROJECT_ID].')
-
- parser.add_argument('--os-tenant-name',
- default=cliutils.env('OS_TENANT_NAME'),
- help='Defaults to env[OS_TENANT_NAME].')
+ parser.add_argument("--os-project-id",
+ default=cliutils.env("OS_PROJECT_ID"),
+ help="Another way to specify tenant ID. "
+ "This option is mutually exclusive with "
+ " --os-tenant-id. "
+ "Defaults to env[OS_PROJECT_ID].")
+
+ parser.add_argument("--os-project-name",
+ default=cliutils.env("OS_PROJECT_NAME"),
+ help="Another way to specify tenant name. "
+ "This option is mutually exclusive with "
+ " --os-tenant-name. "
+ "Defaults to env[OS_PROJECT_NAME].")
+
+ parser.add_argument("--os-tenant-id",
+ default=cliutils.env("OS_TENANT_ID"),
+ help="This option is mutually exclusive with "
+ " --os-project-id. "
+ "Defaults to env[OS_PROJECT_ID].")
+
+ parser.add_argument("--os-tenant-name",
+ default=cliutils.env("OS_TENANT_NAME"),
+ help="Defaults to env[OS_TENANT_NAME].")
# Auth related options
- parser.add_argument('--os-auth-url',
- default=cliutils.env('OS_AUTH_URL'),
- help='Defaults to env[OS_AUTH_URL].')
-
- parser.add_argument('--os-auth-token',
- default=cliutils.env('OS_AUTH_TOKEN'),
- help='Defaults to env[OS_AUTH_TOKEN].')
-
- parser.add_argument('--os-cacert',
- metavar='<ca-certificate-file>',
- dest='os_cacert',
- default=cliutils.env('OS_CACERT'),
- help='Path of CA TLS certificate(s) used to verify'
- ' the remote server\'s certificate. Without this '
- 'option ceilometer looks for the default system CA'
- ' certificates.')
-
- parser.add_argument('--os-cert',
- help='Path of certificate file to use in SSL '
- 'connection. This file can optionally be '
- 'prepended with the private key.')
-
- parser.add_argument('--os-key',
- 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-auth-url",
+ default=cliutils.env("OS_AUTH_URL"),
+ help="Defaults to env[OS_AUTH_URL].")
+
+ parser.add_argument("--os-auth-token",
+ default=cliutils.env("OS_AUTH_TOKEN"),
+ help="Defaults to env[OS_AUTH_TOKEN].")
+
+ parser.add_argument("--os-cacert",
+ metavar="<ca-certificate-file>",
+ dest="os_cacert",
+ default=cliutils.env("OS_CACERT"),
+ help="Path of CA TLS certificate(s) used to verify"
+ " the remote server\"s certificate. Without this "
+ "option ceilometer looks for the default system CA"
+ " certificates.")
+
+ parser.add_argument("--os-cert",
+ help="Path of certificate file to use in SSL "
+ "connection. This file can optionally be "
+ "prepended with the private key.")
+
+ parser.add_argument("--os-key",
+ help="Path of client key to use in SSL "
+ "connection. This option is not necessary "
+ "if your key is prepended to your cert file.")
# Service Catalog related options
- parser.add_argument('--os-service-type',
- default=cliutils.env('OS_SERVICE_TYPE'),
- help='Defaults to env[OS_SERVICE_TYPE].')
+ parser.add_argument("--os-service-type",
+ default=cliutils.env("OS_SERVICE_TYPE"),
+ help="Defaults to env[OS_SERVICE_TYPE].")
- parser.add_argument('--os-endpoint-type',
- default=cliutils.env('OS_ENDPOINT_TYPE'),
- help='Defaults to env[OS_ENDPOINT_TYPE].')
+ parser.add_argument("--os-endpoint-type",
+ default=cliutils.env("OS_ENDPOINT_TYPE"),
+ help="Defaults to env[OS_ENDPOINT_TYPE].")
- parser.add_argument('--os-region-name',
- default=cliutils.env('OS_REGION_NAME'),
- help='Defaults to env[OS_REGION_NAME].')
+ parser.add_argument("--os-region-name",
+ default=cliutils.env("OS_REGION_NAME"),
+ help="Defaults to env[OS_REGION_NAME].")
def _append_subcommands(self, parent_parser):
- subcommands = parent_parser.add_subparsers(help='<subcommands>')
+ subcommands = parent_parser.add_subparsers(help="<subcommands>")
for group_cls in commands.BaseCommand.__subclasses__():
group_parser = subcommands.add_parser(group_cls.group_name)
subcommand_parser = group_parser.add_subparsers()
for name, callback in inspect.getmembers(
group_cls(), predicate=inspect.ismethod):
- command = name.replace('_', '-')
- desc = callback.__doc__ or ''
- help_message = desc.strip().split('\n')[0]
- arguments = getattr(callback, 'arguments', [])
+ command = name.replace("_", "-")
+ desc = callback.__doc__ or ""
+ help_message = desc.strip().split("\n")[0]
+ arguments = getattr(callback, "arguments", [])
command_parser = subcommand_parser.add_parser(
command, help=help_message, description=desc)