watcherclient.common.cliutils
Module¶watcherclient.common.cliutils.
MissingArgs
(missing)[source]¶Bases: Exception
Supplied arguments are not sufficient for calling a function.
watcherclient.common.cliutils.
add_arg
(func, *args, **kwargs)[source]¶Bind CLI arguments to a shell.py do_foo function.
watcherclient.common.cliutils.
arg
(*args, **kwargs)[source]¶Decorator for CLI args.
Example:
>>> @arg("name", help="Name of the new entity")
... def entity_create(args):
... pass
watcherclient.common.cliutils.
env
(*args, **kwargs)[source]¶Returns the first environment variable set.
If all are empty, defaults to ‘’ or keyword arg default.
watcherclient.common.cliutils.
isunauthenticated
(func)[source]¶Checks if the function does not require authentication.
Mark such functions with the @unauthenticated decorator.
Returns: | bool |
---|
watcherclient.common.cliutils.
print_dict
(dct, dict_property='Property', wrap=0)[source]¶Print a dict as a table of two columns.
Parameters: |
|
---|
watcherclient.common.cliutils.
print_list
(objs, fields, formatters=None, sortby_index=0, mixed_case_fields=None, field_labels=None)[source]¶Print a list or objects as a table, one row per object.
Parameters: |
|
---|
watcherclient.common.cliutils.
service_type
(stype)[source]¶Adds ‘service_type’ attribute to decorated function.
Usage:
@service_type('volume')
def mymethod(f):
...
watcherclient.common.cliutils.
unauthenticated
(func)[source]¶Adds ‘unauthenticated’ attribute to decorated function.
Usage:
>>> @unauthenticated
... def mymethod(f):
... pass
watcherclient.common.cliutils.
validate_args
(fn, *args, **kwargs)[source]¶Check that the supplied args are sufficient for calling a function.
>>> validate_args(lambda a: None)
Traceback (most recent call last):
...
MissingArgs: Missing argument(s): a
>>> validate_args(lambda a, b, c, d: None, 0, c=1)
Traceback (most recent call last):
...
MissingArgs: Missing argument(s): b, d
Parameters: |
|
---|
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.