Note that there are some explanatory texts on larger screens.

plurals
  1. POcreating a temporary file in python with FUSE
    text
    copied!<p>I am trying to write a program using python-fuse, but I can't get file writing down. my file_class looks like this</p> <pre><code>class FuseFile(object): def __init__(self, path, flags, *mode): debug(path) #debug(mode); self.file = tempfile.TemporaryFile(*mode); self.fd = self.file.fileno() self.path = path def write(self, buf, offset): head, tail = os.path.split(self.path) self.file.seek(offset); self.file.write(buf); return len(buf) def read(self, length, offset): file = apiCall("readfile",{"file":self.path}).read(); slen = len(file) if length &lt; slen: if offset + size &gt; slen: size = slen - offset buf = file[offset:offset+size] else: buf = '' return file # I don't know if this buff stuff is necesarry... def ftruncate(self, len): self.file.truncate(len); def release(self, flags): self.file.close() def flush(self): self._fflush() def fsync(self, isfsyncfile): self._fflush() if isfsyncfile and hasattr(os, 'fdatasync'): os.fdatasync(self.fd) else: os.fsync(self.fd) def _fflush(self): if 'w' in self.file.mode or 'a' in self.file.mode: self.file.flush() </code></pre> <p>but when I try and edit the file in a editor like VIM I get this: </p> <pre><code>"mnt/stuff.txt" E514: write error (file system full?) WARNING: Original file may be lost or damaged don't quit the editor until the file is successfully written! </code></pre> <p><code>[EDIT]</code> I found the problem, I didn't have a open method, but even so, I eventually took out the file_class to implement the methods in the main FUSE class, because that seems to work better</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload