Check if NFS share is mounted in python script

拥有回忆 提交于 2019-12-13 16:53:31

问题


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.


回答1:


Not really.




回答2:


you cat parse /proc/mount file. Notice, that on different platforms and kernel versions file format may be different.



来源:https://stackoverflow.com/questions/2889490/check-if-nfs-share-is-mounted-in-python-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!