Check if NFS share is set in python script

I wrote a python script that depends on a specific NFS share. If the NFS share is not mounted, it will gladly copy the files to the local path where it should be installed, but will pass later when it tries to copy some files that were created on the NFS server.

I would like to catch this error specifically so that I can print a useful error message that tells users of this script what they should do.

My first idea would be to mount using a subprocess and then check the output for this nfs resource. But I wonder if there is a better and more reliable way to do this.

+2
source share
2 answers

cat parse / proc / mount file. Please note that on different platforms and kernel versions the file format may be different.

+1
source

All Articles