Skip to content

Commit

Permalink
Modified the google style to numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandofloresg committed Mar 30, 2024
1 parent dbe9e53 commit da652c8
Showing 1 changed file with 59 additions and 35 deletions.
94 changes: 59 additions & 35 deletions plugins/modules/zos_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,24 @@


def execute_command(operator_cmd, timeout_s=1, *args, **kwargs):
"""Executes a command
Arguments:
operator_cmd {str} -- Command to execute
timeout {int} -- Time until it stops whether it finished or not
*args {dict} -- Some arguments to pass on
**kwargs {dict} -- Some other arguments to pass on
Returns:
list[int,str,str,int] -- Return code, standard output, standard error and time elapsed from start to finish
"""
Executes an operator command.
Parameters
----------
operator_cmd : str
Command to execute
timeout : int
Time until it stops whether it finished or not
*args : dict
Some arguments to pass on
**kwargs : dict
Some other arguments to pass on
Returns
-------
tuple(int, str, str, int)
Return code, standard output, standard error and time elapsed from start to finish
"""
# as of ZOAU v1.3.0, timeout is measured in centiseconds, therefore:
timeout_c = 100 * timeout_s
Expand All @@ -199,11 +207,12 @@ def execute_command(operator_cmd, timeout_s=1, *args, **kwargs):
def run_module():
"""Initialize the module
Raises:
fail_json: An error ocurred while importing ZOAU
Raises
------
fail_json: An error ocurred while importing ZOAU.
fail_json: Expected response to be more than 2 lines.
fail_json: A non-zero return code was received
fail_json: An unexpected error occurred
fail_json: A non-zero return code was received.
fail_json: An unexpected error occurred.
"""
module_args = dict(
cmd=dict(type="str", required=True),
Expand Down Expand Up @@ -279,13 +288,17 @@ def run_module():


def parse_params(params):
"""Parse parameters
"""Use BetterArgParser to parse the module parameters.
Arguments:
params {dict} -- Parameters to parse
Parameters
----------
params : dict
Parameters to parse
Returns:
dict -- New parameters
Returns
-------
dict
New parameters
"""
arg_defs = dict(
cmd=dict(arg_type="str", required=True),
Expand All @@ -298,13 +311,18 @@ def parse_params(params):


def run_operator_command(params):
"""Run operator command
Arguments:
params {dict} -- Parameters to pass on the function
Returns:
dict -- Return code, standard output, standard error, the cmd call and time elapsed from beginning to end
"""Runs operator command based on a given parameters in a dictionary.
Parameters
----------
params : dict
Operator command parameters to pass into the function.
Returns
-------
dict
Return code, standard output, standard error, the cmd call
and time elapsed from beginning to end.
"""
AnsibleModuleHelper(argument_spec={})

Expand Down Expand Up @@ -345,15 +363,21 @@ class Error(Exception):


class OperatorCmdError(Error):
"""An error occurred executing the operator command
Arguments:
cmd {str} -- Command that failed
rc {int} -- Return code
message {str} -- Human readable string describing the exception
Attributes:
msg {str} -- Human readable string describing the exception
"""Exception raised when an error occurred executing the operator command.
Parameters
----------
cmd : str
Command that failed.
rc : int
Return code.
message : str
Human readable string describing the exception.
Attributes
----------
msg : str
Human readable string describing the exception.
"""
def __init__(self, cmd, rc, message):
self.msg = 'An error occurred executing the operator command "{0}", with RC={1} and response "{2}"'.format(
Expand Down

0 comments on commit da652c8

Please sign in to comment.