Check if NFS share is mounted in python script

Posted by Fabian on Stack Overflow See other posts from Stack Overflow or by Fabian
Published on 2010-05-22T19:32:45Z Indexed on 2010/05/22 19:40 UTC
Read the original article Hit count: 200

Filed under:
|

I wrote a python script that depends on a certain NFS share to be available. If the NFS share is not mounted it will happily copy the files to the local path where it should be mounted, but fail later when it tries to copy some files back that were created on the NFS server.

I'd like to catch this error specifically so I can print a useful error message that will tell the users of this script what they have to do.

My first idea would be to execute mount using subprocess and then check the output for this nfs share. But I'm wondering if there isn't a nicer and more robust method of doing it.

© Stack Overflow or respective owner

Related posts about python

Related posts about nfs