Python load_entry_point 简述

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
        ...
  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值