'transfer a file from local to lxc'

def put_file(self, in_path, out_path):

    super(Connection, self).put_file(in_path, out_path)
    self._display.vvv(('PUT    %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')
    if (not os.path.exists(in_path)):
        msg = ('file    or    module    does    not    exist:    %s' % in_path)
        raise errors.AnsibleFileNotFound(msg)
    try:
        src_file = open(in_path, 'rb')
    except IOError:
        traceback.print_exc()
        raise errors.AnsibleError(('failed    to    open    input    file    to    %s' % in_path))
    try:
        def write_file(args):
            with open(out_path, 'wb+') as dst_file:
                shutil.copyfileobj(src_file, dst_file)
        try:
            self.container.attach_wait(write_file, None)
        except IOError:
            traceback.print_exc()
            msg = ('failed    to    transfer    file    to    %s' % out_path)
            raise errors.AnsibleError(msg)
    finally:
        src_file.close()
