Python fabric.api与fabric.operation

Python fabric.api与fabric.operation,python,fabric,Python,Fabric,我不熟悉Python和Fabric,使用Fabric==1.10.1和Python2.7.6。我不理解fabric.api和fabric.operations调用之间的区别,两者似乎在做相同的事情。我应该在fabfile中使用哪一个?我注意到的一件事是,当我执行fabric.api.reboot()时,它确实会显示消息 [127.0.0.1] out: Broadcast message from vagrant@localhost.localdomain [127.0.0.1] out: [1

我不熟悉Python和Fabric,使用Fabric==1.10.1和Python2.7.6。我不理解fabric.api和fabric.operations调用之间的区别,两者似乎在做相同的事情。我应该在fabfile中使用哪一个?我注意到的一件事是,当我执行
fabric.api.reboot()时,它确实会显示消息

[127.0.0.1] out: Broadcast message from vagrant@localhost.localdomain
[127.0.0.1] out:
[127.0.0.1] out:    (/dev/pts/0) at 17:39 ...
[127.0.0.1] out:
[127.0.0.1] out:
[127.0.0.1] out:
[127.0.0.1] out:
[127.0.0.1] out: The system is going down for reboot NOW!
[127.0.0.1] out:
但是当我使用
fabric.operations.reboot()
时,它不会显示任何消息


更新:实际上似乎是
fabric.operations.reboot()
fabric.api.reboot()
生成消息。

您可以使用其中任何一种,但
fabric.api
是更好的选择。这是因为为了简单起见,其他结构模块都是在这里导入的。请看这里:

$ cat fabric/api.py                                                                                                                                                                                                                                          (env: selenium)
"""
Non-init module for doing convenient * imports from.

Necessary because if we did this in __init__, one would be unable to import
anything else inside the package -- like, say, the version number used in
setup.py -- without triggering loads of most of the code. Which doesn't work so
well when you're using setup.py to install e.g. ssh!
"""
from fabric.context_managers import (cd, hide, settings, show, path, prefix,
    lcd, quiet, warn_only, remote_tunnel, shell_env)
from fabric.decorators import (hosts, roles, runs_once, with_settings, task,
        serial, parallel)
from fabric.operations import (require, prompt, put, get, run, sudo, local,
    reboot, open_shell)
from fabric.state import env, output
from fabric.utils import abort, warn, puts, fastprint
from fabric.tasks import execute

fabric.api
正在导入
fabric.operations。已经为您重新启动了。

谢谢@Morgan,感谢您的回复!