本文整理汇总了Python中sos.policies.PackageManager.all_files方法的典型用法代码示例。如果您正苦于以下问题:Python PackageManager.all_files方法的具体用法?Python PackageManager.all_files怎么用?Python PackageManager.all_files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sos.policies.PackageManager
的用法示例。
在下文中一共展示了PackageManager.all_files方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RedHatPolicy
# 需要导入模块: from sos.policies import PackageManager [as 别名]
# 或者: from sos.policies.PackageManager import all_files [as 别名]
class RedHatPolicy(LinuxPolicy):
distro = "Red Hat"
vendor = "Red Hat"
vendor_url = "http://www.redhat.com/"
_redhat_release = '/etc/redhat-release'
_tmp_dir = "/var/tmp"
_rpmq_cmd = 'rpm -qa --queryformat "%{NAME}|%{VERSION}|%{RELEASE}\\n"'
_rpmql_cmd = 'rpm -qal'
_rpmv_cmd = 'rpm -V'
_rpmv_filter = ["debuginfo", "-devel"]
_in_container = False
_host_sysroot = '/'
default_scl_prefix = '/opt/rh'
name_pattern = 'friendly'
init = 'systemd'
def __init__(self, sysroot=None):
super(RedHatPolicy, self).__init__(sysroot=sysroot)
self.ticket_number = ""
self.usrmove = False
# need to set _host_sysroot before PackageManager()
if sysroot:
self._container_init()
self._host_sysroot = sysroot
else:
sysroot = self._container_init()
self.package_manager = PackageManager(query_command=self._rpmq_cmd,
verify_command=self._rpmv_cmd,
verify_filter=self._rpmv_filter,
files_command=self._rpmql_cmd,
chroot=sysroot)
self.valid_subclasses = [RedHatPlugin]
self.pkgs = self.package_manager.all_pkgs()
files = self.package_manager.all_files()
# If rpm query failed, exit
if not self.pkgs:
print("Could not obtain installed package list", file=sys.stderr)
sys.exit(1)
# If the files rpm query failed, exit
if not files:
print("Could not obtain the files list known to the package \
manager", file=sys.stderr)
sys.exit(1)
self.usrmove = self.check_usrmove(self.pkgs)
if self.usrmove:
self.PATH = "/usr/sbin:/usr/bin:/root/bin"
else:
self.PATH = "/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
self.PATH += os.pathsep + "/usr/local/bin"
self.PATH += os.pathsep + "/usr/local/sbin"
self.set_exec_path()
self.load_presets()
@classmethod
def check(cls):
"""This method checks to see if we are running on Red Hat. It must be
overriden by concrete subclasses to return True when running on a
Fedora, RHEL or other Red Hat distribution or False otherwise."""
return False
def check_usrmove(self, pkgs):
"""Test whether the running system implements UsrMove.
If the 'filesystem' package is present, it will check that the
version is greater than 3. If the package is not present the
'/bin' and '/sbin' paths are checked and UsrMove is assumed
if both are symbolic links.
:param pkgs: a packages dictionary
"""
if 'filesystem' not in pkgs:
return os.path.islink('/bin') and os.path.islink('/sbin')
else:
filesys_version = pkgs['filesystem']['version']
return True if filesys_version[0] == '3' else False
def mangle_package_path(self, files):
"""Mangle paths for post-UsrMove systems.
If the system implements UsrMove, all files will be in
'/usr/[s]bin'. This method substitutes all the /[s]bin
references in the 'files' list with '/usr/[s]bin'.
:param files: the list of package managed files
"""
paths = []
def transform_path(path):
# Some packages actually own paths in /bin: in this case,
# duplicate the path as both the / and /usr version.
skip_paths = ["/bin/rpm", "/bin/mailx"]
if path in skip_paths:
return (path, os.path.join("/usr", path[1:]))
#.........这里部分代码省略.........