fab是个python语言写的部署工具
cat /usr/bin/fab
#!/usr/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'Fabric==1.7.5','console_scripts','fab'
__requires__ = 'Fabric==1.7.5'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('Fabric==1.7.5', 'console_scripts', 'fab')()
)
其中load_entry_point的用法前提是,fab工具在安装的时候会在*..egg-info文件夹下面的entry_points.txt文件中有相应程序的入口点。
/usr/lib/python2.7/site-packages/Fabric-1.7.5-py2.7.egg-info/entry_points.txt
[console_scripts]
fab = fabric.main:main
也就是在fabric module的main.py里面的main函数
/usr/lib/python2.7/site-packages/fabric/main.py
"""
This module contains Fab's `main` method plus related subroutines.
`main` is executed as the command line ``fab`` program and takes care of
parsing options and commands, loading the user settings file, loading a
fabfile, and executing the commands given.
The other callables defined in this module are internal only. Anything useful
to individuals leveraging Fabric as a library, should be kept elsewhere.
"""
def main(fabfile_locations=None):
"""
Main command-line execution loop.
"""
try:
# Parse command line options
parser, options, arguments = parse_options()
# Handle regular args vs -- args
arguments = parser.largs
remainder_arguments = parser.rargs
...