开发者

Check if NFS share is mounted in python script

开发者 https://www.devze.com 2023-01-01 05:01 出处:网络
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

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 o开发者_运维知识库f doing it.


Not really.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消