tags:

views:

194

answers:

1

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.

+2  A: 

Not really.

Ignacio Vazquez-Abrams
I'm confused. The linked answers seem to indicate that what the OP wants to do is very much possible. Would you mind explaining your "Not really"?
yarmiganosca
"But I'm wondering if there isn't a nicer and more robust method of doing it." "Not really."
Ignacio Vazquez-Abrams
Thanks, the os.path.ismount() function is sufficient for my purposes and it is a much cleaner solution. It does not protect against mounting the wrong volume, but that is not really a concern in this case as I'm administering the mounts myself. The information that "something" is mounted at that path is enough.
Fabian
@Ignacio: *forehead smack* Thank you.
yarmiganosca