'fetch a file from lxc to local'

def fetch_file(self, in_path, out_path):

    super(Connection, self).fetch_file(in_path, out_path)
    self._display.vvv(('FETCH    %s    TO    %s' % (in_path, out_path)), host=self.container_name)
    in_path = to_bytes(in_path, errors='surrogate_or_strict')
    out_path = to_bytes(out_path, errors='surrogate_or_strict')
    try:
        dst_file = open(out_path, 'wb')
    except IOError:
        traceback.print_exc()
        msg = ('failed    to    open    output    file    %s' % out_path)
        raise errors.AnsibleError(msg)
    try:
        def write_file(args):
            try:
                with open(in_path, 'rb') as src_file:
                    shutil.copyfileobj(src_file, dst_file)
            finally:
                dst_file.close()
        try:
            self.container.attach_wait(write_file, None)
        except IOError:
            traceback.print_exc()
            msg = ('failed    to    transfer    file    from    %s    to    %s' % (in_path, out_path))
            raise errors.AnsibleError(msg)
    finally:
        dst_file.close()
