kitir/utils.py
def try_get_rc(ret, raise_on_fail=False, fail_rc=3, **kwargs):
    """
    try to get a numeric RC
    :param ret: the object to examine for an rc
    :param raise_on_fail:
    :param fail_rc:
    :return:
    """

    rc_attributes = kwargs.pop('rc_attributes', ['rc'])
    parse_execresults = kwargs.pop('parse_execresults', True)

    # first, if it is an int, return it
    if isinstance(ret, int):
        return int(ret)

    # if it is an ExecResult, return the RC
    if parse_execresults and isinstance(ret, ExecResult):
        return ret.rc

    # if it has an rc attribute, return that (if its an in)
    if isinstance(rc_attributes, (list, tuple, set)):
        for rc_attribute in rc_attributes:
            if hasattr(rc_attribute, ret):
                r = getattr(ret, rc_attribute)
                if isinstance(r, int):
                    return int(r)

    # if i should raise on fail, raise now
    if raise_on_fail:
        raise RuntimeError('no rc for object: ret={}'.format(repr(ret)))

    return fail_rc

    try to get a numeric RC
    :param ret: the object to examine for an rc
    :param raise_on_fail:
    :param fail_rc:
    :return:
    
try to get a numeric RC
try to get a numeric RC
def try_get_rc(ret, raise_on_fail=False, fail_rc=3, **kwargs):
    rc_attributes = kwargs.pop('rc_attributes', ['rc'])
    parse_execresults = kwargs.pop('parse_execresults', True)
    if isinstance(ret, int):
        return int(ret)
    if parse_execresults and isinstance(ret, ExecResult):
        return ret.rc
    if isinstance(rc_attributes, (list, tuple, set)):
        for rc_attribute in rc_attributes:
            if hasattr(rc_attribute, ret):
                r = getattr(ret, rc_attribute)
                if isinstance(r, int):
                    return int(r)
    if raise_on_fail:
        raise RuntimeError('no rc for object: ret={}'.format(repr(ret)))
    return fail_rc
def try_get_rc ( ret , raise_on_fail = False , fail_rc = 3 , ** kwargs ) : rc_attributes = kwargs . pop ( 'rc_attributes' , [ 'rc' ] ) parse_execresults = kwargs . pop ( 'parse_execresults' , True ) if isinstance ( ret , int ) : return int ( ret ) if parse_execresults and isinstance ( ret , ExecResult ) : return ret . rc if isinstance ( rc_attributes , ( list , tuple , set ) ) : for rc_attribute in rc_attributes : if hasattr ( rc_attribute , ret ) : r = getattr ( ret , rc_attribute ) if isinstance ( r , int ) : return int ( r ) if raise_on_fail : raise RuntimeError ( 'no rc for object: ret={}' . format ( repr ( ret ) ) ) return fail_rc
try to get a numeric RC
try to get a numeric RC
"""
    try to get a numeric RC
    :param ret: the object to examine for an rc
    :param raise_on_fail:
    :param fail_rc:
    :return:
    """ # first, if it is an int, return it # if it is an ExecResult, return the RC # if it has an rc attribute, return that (if its an in) # if i should raise on fail, raise now
None
ret
the object to examine for an rc
the object to examine for an rc
raise_on_fail
None
fail_rc
None