def fsinit(self): self.mongo = MongoClient( self.host, document_class=SON, connectTimeoutMS=2000, socketTimeoutMS=2000, socketKeepAlive=True ) notify( "MongoFS", 'Mounted <i>%s</i> on <a href="%s"><i>%s</i></a>' % (self.host, path2url(self.fuse_args.mountpoint), os.path.abspath(self.fuse_args.mountpoint)), icon="dialog-information", )
def flush(self, fh): if not fh.dirty: return fh.flush_ret try: json = fh.buffer.getvalue() if len(json.strip()): doc = loads(json.decode(self.mongofs.json_encoding, errors="replace")) else: doc = {} except ValueError, e: notify("Invalid MongoFS document", "\n".join(str(e).split(":"))) fh.dirty = False fh.flush_ret = -errno.EIO return fh.flush_ret