如何依赖于系统命令与python / distutils? [英] How to depends of a system command with python/distutils?
问题描述
我正在寻找最优雅的方式通知我的图书馆的用户,他们需要一个特定的unix命令,以确保它将工作...
是我的lib提出错误的赌注时间:
- 安装?
-
< b
还应该如何检测命令是否丢失(如果不是commands.getoutput(which CommandIDependsOn):raise Exception(你需要CommandIDependsOn)$
<我不会有任何检查。记录你的库需要这个命令,如果用户试图使用库的任何部分需要它,运行命令将引发异常。
(PS: commands
subprocess
是热的新东西。) I'm looking for the most elegant way to notify users of my library that they need a specific unix command to ensure that it will works...
When is the bet time for my lib to raise an error:
- Installation ?
- When my app call the command ?
- At the import of my lib ?
- both?
And also how should you detect that the command is missing (if not commands.getoutput("which CommandIDependsOn"): raise Exception("you need CommandIDependsOn")
).
I need advices.
I wouldn't have any check at all. Document that your library requires this command, and if the user tries to use whatever part of your library needs it, an exception will be raised by whatever runs the command. It should still be possible to import your library and use it, even if only a subset of functionality is offered.
(PS: commands
is old and broken and shouldn't be used in new code. subprocess
is the hot new stuff.)
这篇关于如何依赖于系统命令与python / distutils?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!