检查NFS共享是否已安装在python脚本中 [英] Check if NFS share is mounted in python script

查看:173
本文介绍了检查NFS共享是否已安装在python脚本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个python脚本,该脚本取决于特定的NFS共享是否可用.如果未挂载NFS共享,它将很乐意将文件复制到应挂载的本地路径,但是稍后在尝试将某些在NFS服务器上创建的文件复制回本地时失败.

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.

我的第一个想法是使用子进程执行挂载,然后检查此nfs共享的输出.但是我想知道是否没有更好,更强大的方法来做到这一点.

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.

推荐答案

Not really.

这篇关于检查NFS共享是否已安装在python脚本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆