'Get information from remote file.'

def _execute_remote_stat(self, path, all_vars, follow, tmp=None, checksum=True):

    module_args = dict(path=path, follow=follow, get_md5=False, get_checksum=checksum, checksum_algo='sha1')
    mystat = self._execute_module(module_name='stat', module_args=module_args, task_vars=all_vars, tmp=tmp, delete_remote_tmp=(tmp is None), wrap_async=False)
    if mystat.get('failed'):
        msg = mystat.get('module_stderr')
        if (not msg):
            msg = mystat.get('module_stdout')
        if (not msg):
            msg = mystat.get('msg')
        raise AnsibleError(('Failed    to    get    information    on    remote    file    (%s):    %s' % (path, msg)))
    if (not mystat['stat']['exists']):
        mystat['stat']['checksum'] = '1'
    if ('checksum' not in mystat['stat']):
        mystat['stat']['checksum'] = ''
    elif (not isinstance(mystat['stat']['checksum'], string_types)):
        raise AnsibleError(('Invalid    checksum    returned    by    stat:    expected    a    string    type    but    got    %s' % type(mystat['stat']['checksum'])))
    return mystat['stat']
