コード例 #1
0
ファイル: pkg_resource.py プロジェクト: sitepoint/salt
 def parse_rpm(path):
     try:
         from salt.modules.yumpkg5 import __QUERYFORMAT, _parse_pkginfo
         from salt.utils import namespaced_function
         _parse_pkginfo = namespaced_function(_parse_pkginfo, globals())
     except ImportError:
         log.critical('Error importing helper functions. This is almost '
                      'certainly a bug.')
         return '', ''
     pkginfo = __salt__['cmd.run_all'](
         'rpm -qp --queryformat {0!r} {1!r}'.format(__QUERYFORMAT, path)
     ).get('stdout', '').strip()
     pkginfo = _parse_pkginfo(pkginfo)
     if pkginfo is None:
         return '', ''
     else:
         return pkginfo.name, pkginfo.version
コード例 #2
0
ファイル: pkg_resource.py プロジェクト: yanghao-zh/salt
 def parse_rpm(path):
     try:
         import collections  # needed by _parse_pkginfo, DO NOT REMOVE
         from salt.modules.yumpkg5 import __QUERYFORMAT, _parse_pkginfo
         from salt.utils import namespaced_function as _namespaced_function
         _parse_pkginfo = _namespaced_function(_parse_pkginfo, globals())
     except ImportError:
         log.critical('Error importing helper functions. This is almost '
                      'certainly a bug.')
         return '', ''
     pkginfo = __salt__['cmd.run_all'](
         'rpm -qp --queryformat {0!r} {1!r}'.format(
             __QUERYFORMAT, path)).get('stdout', '').strip()
     pkginfo = _parse_pkginfo(pkginfo)
     if pkginfo is None:
         return '', ''
     else:
         return pkginfo.name, pkginfo.version
コード例 #3
0
ファイル: pkg_resource.py プロジェクト: joehealy/pkg-salt
    def parse_rpm(path):
        try:
            import collections  # needed by _parse_pkginfo, DO NOT REMOVE
            from salt.modules.yumpkg5 import __QUERYFORMAT, _parse_pkginfo
            from salt.utils import namespaced_function as _namespaced_function

            _parse_pkginfo = _namespaced_function(_parse_pkginfo, globals())
        except ImportError:
            log.critical("Error importing helper functions. This is almost " "certainly a bug.")
            return "", ""
        pkginfo = (
            __salt__["cmd.run_all"]("rpm -qp --queryformat {0!r} {1!r}".format(__QUERYFORMAT, path))
            .get("stdout", "")
            .strip()
        )
        pkginfo = _parse_pkginfo(pkginfo)
        if pkginfo is None:
            return "", ""
        else:
            return pkginfo.name, pkginfo.version
コード例 #4
0
ファイル: pkg_resource.py プロジェクト: zeus911/salt
 def parse_rpm(path):
     try:
         from salt.modules.yumpkg5 import __QUERYFORMAT, _parse_pkginfo
         from salt.utils import namespaced_function as _namespaced_function
         _parse_pkginfo = _namespaced_function(_parse_pkginfo, globals())
     except ImportError:
         log.critical('Error importing helper functions. This is almost '
                      'certainly a bug.')
         return '', ''
     pkginfo = __salt__['cmd.run_stdout'](
         'rpm -qp --queryformat {0!r} {1!r}'.format(
             # Binary packages have no REPOID, replace this so the rpm
             # command does not fail with "invalid tag" error
             __QUERYFORMAT.replace('%{REPOID}', 'binarypkg'),
             path.encode('ascii', 'ignore'))).strip()
     pkginfo = _parse_pkginfo(pkginfo)
     if pkginfo is None:
         return '', ''
     else:
         return pkginfo.name, pkginfo.version
コード例 #5
0
ファイル: pkg_resource.py プロジェクト: MadeiraCloud/salt
 def parse_rpm(path):
     try:
         from salt.modules.yumpkg5 import __QUERYFORMAT, _parse_pkginfo
         from salt.utils import namespaced_function as _namespaced_function
         _parse_pkginfo = _namespaced_function(_parse_pkginfo, globals())
     except ImportError:
         log.critical('Error importing helper functions. This is almost '
                      'certainly a bug.')
         return '', ''
     pkginfo = __salt__['cmd.run_stdout'](
         'rpm -qp --queryformat {0!r} {1!r}'.format(
             # Binary packages have no REPOID, replace this so the rpm
             # command does not fail with "invalid tag" error
             __QUERYFORMAT.replace('%{REPOID}', 'binarypkg'),
             path.encode('ascii','ignore')
         )
     ).strip()
     pkginfo = _parse_pkginfo(pkginfo)
     if pkginfo is None:
         return '', ''
     else:
         return pkginfo.name, pkginfo.version