Set the return code based on the data back from the state system

def _set_retcode(ret, highstate=None):
    '''
    Set the return code based on the data back from the state system
    '''

    # Set default retcode to 0
    __context__['retcode'] = 0

    if isinstance(ret, list):
        __context__['retcode'] = 1
        return
    if not salt.utils.state.check_result(ret, highstate=highstate):

        __context__['retcode'] = 2