• 大小: 13.24MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-26
  • 语言: Python
  • 标签: 工具  

资源简介

Ansible:一个非常简单的 IT 自动化平台 。让你的应用程序和系统更容易部署。

资源截图

代码片段和文件信息


import json
import os
import os.path
import re
import sys
from collections import defaultdict
from distutils.command.build_scripts import build_scripts as Buildscripts
from distutils.command.sdist import sdist as SDist

try:
    from setuptools import setup find_packages
    from setuptools.command.build_py import build_py as BuildPy
    from setuptools.command.install_lib import install_lib as InstallLib
    from setuptools.command.install_scripts import install_scripts as Installscripts
except ImportError:
    print(“Ansible now needs setuptools in order to build. Install it using“
          “ your package manager (usually python-setuptools) or via pip (pip“
          “ install setuptools).“)
    sys.exit(1)

sys.path.insert(0 os.path.abspath(‘lib‘))
from ansible.release import __version__ __author__


SYMlink_CACHE = ‘SYMlink_CACHE.json‘


def _find_symlinks(topdir extension=‘‘):
    “““Find symlinks that should be maintained

    Maintained symlinks exist in the bin dir or are modules which have
    aliases.  Our heuristic is that they are a link in a certain path which
    point to a file in the same directory.
    “““
    symlinks = defaultdict(list)
    for base_path dirs files in os.walk(topdir):
        for filename in files:
            filepath = os.path.join(base_path filename)
            if os.path.islink(filepath) and filename.endswith(extension):
                target = os.readlink(filepath)
                if os.path.dirname(target) == ‘‘:
                    link = filepath[len(topdir):]
                    if link.startswith(‘/‘):
                        link = link[1:]
                    symlinks[os.path.basename(target)].append(link)
    return symlinks


def _cache_symlinks(symlink_data):
    with open(SYMlink_CACHE ‘w‘) as f:
        f.write(json.dumps(symlink_data))


def _maintain_symlinks(symlink_type base_path):
    “““Switch a real file into a symlink“““
    try:
        # Try the cache first because going from git checkout to sdist is the
        # only time we know that we‘re going to cache correctly
        with open(SYMlink_CACHE ‘r‘) as f:
            symlink_data = json.loads(f.read())
    except (IOError OSError) as e:
        # IOError on py2 OSError on py3.  Both have errno
        if e.errno == 2:
            # SYMlinkS_CACHE doesn‘t exist.  Fallback to trying to create the
            # cache now.  Will work if we‘re running directly from a git
            # checkout or from an sdist created earlier.
            symlink_data = {‘script‘: _find_symlinks(‘bin‘)
                            ‘library‘: _find_symlinks(‘lib‘ ‘.py‘)
                            }

            # Sanity check that something we know should be a symlink was
            # found.  We‘ll take that to mean that the current directory
            # structure properly reflects symlinks in the git repo
            if ‘ansible-playbook‘ in symlink_data[‘script‘][‘ansible‘]:
                _cache_symlinks(symlink_data)
         

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-02-09 02:44  ansible-ansible-80fff4a\
     文件         903  2018-02-09 02:44  ansible-ansible-80fff4a\.coveragerc
     文件          99  2018-02-09 02:44  ansible-ansible-80fff4a\.gitattributes
     文件        2370  2018-02-09 02:44  ansible-ansible-80fff4a\.gitignore
     文件           0  2018-02-09 02:44  ansible-ansible-80fff4a\.gitmodules
     文件        2200  2018-02-09 02:44  ansible-ansible-80fff4a\.mailmap
     文件          39  2018-02-09 02:44  ansible-ansible-80fff4a\.yamllint
     文件      200263  2018-02-09 02:44  ansible-ansible-80fff4a\CHANGELOG.md
     文件       10490  2018-02-09 02:44  ansible-ansible-80fff4a\CODING_GUIDELINES.md
     文件        1375  2018-02-09 02:44  ansible-ansible-80fff4a\CONTRIBUTING.md
     文件       35148  2018-02-09 02:44  ansible-ansible-80fff4a\COPYING
     文件         588  2018-02-09 02:44  ansible-ansible-80fff4a\MANIFEST.in
     文件         200  2018-02-09 02:44  ansible-ansible-80fff4a\MODULE_GUIDELINES.md
     文件       11912  2018-02-09 02:44  ansible-ansible-80fff4a\Makefile
     文件        3692  2018-02-09 02:44  ansible-ansible-80fff4a\README.md
     文件        3436  2018-02-09 02:44  ansible-ansible-80fff4a\RELEASES.txt
     文件        1542  2018-02-09 02:44  ansible-ansible-80fff4a\ROADMAP.rst
     文件           9  2018-02-09 02:44  ansible-ansible-80fff4a\VERSION
     文件       78657  2018-02-09 02:44  ansible-ansible-80fff4a\ansible-core-sitemap.xml
     目录           0  2018-02-09 02:44  ansible-ansible-80fff4a\bin\
     文件        5846  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible
     文件           7  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-config
     文件        9898  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-connection
     文件           7  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-console
     文件           7  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-doc
     文件           7  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-galaxy
     文件           7  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-inventory
     文件           7  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-playbook
     文件           7  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-pull
     文件           7  2018-02-09 02:44  ansible-ansible-80fff4a\bin\ansible-vault
     目录           0  2018-02-09 02:44  ansible-ansible-80fff4a\contrib\
............此处省略11836个文件信息

评论

共有 条评论