From 07030f4b4be2fb32efd8e9452bfca076d98ee416 Mon Sep 17 00:00:00 2001 From: rfkelly0 Date: Mon, 8 Jun 2009 02:27:04 +0000 Subject: allowing MountProcess to report mount failure errors git-svn-id: http://pyfilesystem.googlecode.com/svn/branches/rfk-ideas@162 67cdc799-7952-0410-af00-57a81ceafa0f --- fs/expose/fuse/__init__.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/fs/expose/fuse/__init__.py b/fs/expose/fuse/__init__.py index 156aa96..4bae8d1 100644 --- a/fs/expose/fuse/__init__.py +++ b/fs/expose/fuse/__init__.py @@ -391,7 +391,8 @@ class MountProcess(subprocess.Popen): cmd = [sys.executable,"-c",cmd] super(MountProcess,self).__init__(cmd,**kwds) os.close(w) - os.read(r,1) + if os.read(r,1) != "S": + raise RuntimeError("A FUSE error occurred") def unmount(self): """Cleanly unmount the FUSE filesystem, terminating this subprocess.""" @@ -413,8 +414,19 @@ class MountProcess(subprocess.Popen): (fs,path,opts,r,w) = pickle.loads(data) os.close(r) opts["foreground"] = True - opts["ready_callback"] = lambda: os.close(w) - mount(fs,path,**opts) + successful = [] + def ready_callback(): + successful.append(True) + os.write(w,"S") + os.close(w) + opts["ready_callback"] = ready_callback + try: + mount(fs,path,**opts) + except Exception: + pass + if not successful: + os.write(w,"E") + if __name__ == "__main__": -- cgit v1.2.1