Return name, version and if rpm package for specified target
494077
def _check_pkg(target):
    '''
    
    '''
    ret = {}
    cmd = ['/usr/bin/lslpp', '-Lc', target]
    lines = __salt__['cmd.run'](
            cmd,
            python_shell=False).splitlines()

    name = ''
    version_num = ''
    rpmpkg = False
    for line in lines:
        if line.startswith('#'):
            continue

        comps = line.split(':')
        if len(comps) < 7:
            raise CommandExecutionError(
                'Error occurred finding fileset/package',
                info={'errors': comps[1].strip()})

        # handle first matching line
        if 'R' in comps[6]:
            name = comps[0]
            rpmpkg = True
        else:
            name = comps[1]     # use fileset rather than rpm package

        version_num = comps[2]
        break

    return name, version_num, rpmpkg
996891
def get_version():
    """"""
    pkg_dir = get_package_dir()
    with open(os.path.join(pkg_dir, 'nestcheck/_version.py')) as ver_file:
        string = ver_file.read()
    return string.strip().replace('__version__ = ', '').replace('\'', '')
133913
def _get_version(name, results):
    '''
    
    '''
    for line in salt.utils.itertools.split(results, '\n'):
        if not line:
            continue
        try:
            pkgname, pkgver = line.rsplit('-', 1)
        except ValueError:
            continue
        if pkgname == name:
            return pkgver
    return None
1050510
def get_installer_desc(build_context, target) -> tuple:
    """"""
    workspace_dir = build_context.get_workspace('CustomInstaller', target.name)
    target_name = split_name(target.name)
    script_name = basename(target.props.script)
    package_tarball = '{}.tar.gz'.format(join(workspace_dir, target_name))
    return target_name, script_name, package_tarball
86420
def get_version():
    
    try:
        version_file = open(os.path.join(ROOT_DIR, 'mollie', 'api', 'version.py'), encoding='utf=8')
    except TypeError:
        # support python 2
        version_file = open(os.path.join(ROOT_DIR, 'mollie', 'api', 'version.py'))
    contents = version_file.read()
    match = re.search(r'VERSION = [\'"]([^\'"]+)', contents)
    if match:
        return match.group(1)
    else:
        raise RuntimeError("Can't determine package version")
1328829
def _get_distset(tgt):
    '''
    
    '''
    # Centos adds 'centos' string to rpm names, removing that to have
    # consistent naming on Centos and Redhat, and allow for Amazon naming
    tgtattrs = tgt.split('-')
    if tgtattrs[0] == 'amzn':
        distset = '--define "dist .{0}1"'.format(tgtattrs[0])
    elif tgtattrs[1] in ['6', '7']:
        distset = '--define "dist .el{0}"'.format(tgtattrs[1])
    else:
        distset = ''

    return distset
658535
def _get_version():
    """"""
    with open(os.path.join(os.path.dirname(__file__), PACKAGE_NAME, 'VERSION'), 'rb') as f:
        version = f.read().decode('ascii').strip()
    return version
66370
def _kernel_versions_redhat():
    '''
    
    '''
    kernel_get_last = __salt__['cmd.run']('rpm -q --last kernel')
    kernels = []
    kernel_versions = []
    for line in kernel_get_last.splitlines():
        if 'kernel-' in line:
            kernels.append(line)

    kernel = kernels[0].split(' ', 1)[0]
    kernel = kernel.strip('kernel-')
    kernel_versions.append(kernel)

    return kernel_versions
211400
def verify_package_status(self):
        """"""
        # rpm-libs is required for /usr/lib64/librpm*.so
        self.rpm.verify_packages_installed(['rpm-libs'])

        # Check RPM so files to build the Python binding.
        message_format = '''
RPM: {0} or
RPM download tool (dnf-plugins-core (dnf) or yum-utils (yum)) required.
Install any of those.
'''
        if self.rpm.has_composed_rpm_bulid_libs():
            if (not self.rpm.is_package_installed('rpm-build-libs')
               and not self.rpm.is_downloadable()):
                raise InstallError(message_format.format('rpm-build-libs'))
        else:
            # All the needed so files are included in rpm-libs package.
            pass
954841
def get_pkg_version():
    """"""
    try:
        with open("PKG-INFO", "r") as fp:
            rgx = re.compile(r"Version: (\d+)")
            for line in fp.readlines():
                match = rgx.match(line)
                if match:
                    return match.group(1)
    except IOError:
        return None
977760
def get_rpms(self):
        

        tags = [
            'NAME',
            'VERSION',
            'RELEASE',
            'ARCH',
            'EPOCH',
            'SIGMD5',
            'SIGPGP:pgpsig',
            'SIGGPG:pgpsig',
        ]

        cmd = "/bin/rpm " + rpm_qf_args(tags)
        try:
            # py3
            (status, output) = subprocess.getstatusoutput(cmd)
        except AttributeError:
            # py2
            with open('/dev/null', 'r+') as devnull:
                p = subprocess.Popen(cmd,
                                     shell=True,
                                     stdin=devnull,
                                     stdout=subprocess.PIPE,
                                     stderr=devnull)

                (stdout, stderr) = p.communicate()
                status = p.wait()
                output = stdout.decode()

        if status != 0:
            self.log.debug("%s: stderr output: %s", cmd, stderr)
            raise RuntimeError("%s: exit code %s" % (cmd, status))

        return parse_rpm_output(output.splitlines(), tags)
155635
def get_version():
    """"""
    version = 'Not installed.'

    try:
        version = pkg_resources.get_distribution(__package__).version
    except pkg_resources.DistributionNotFound:
        pass

    return version
219447
def version(*names, **kwargs):
    '''
    
    '''
    ret = {}
    versions_as_list = \
        salt.utils.data.is_true(kwargs.pop('versions_as_list', False))
    pkg_glob = False
    if names:
        pkgs = __salt__['pkg.list_pkgs'](versions_as_list=True, **kwargs)
        for name in names:
            if '*' in name:
                pkg_glob = True
                for match in fnmatch.filter(pkgs, name):
                    ret[match] = pkgs.get(match, [])
            else:
                ret[name] = pkgs.get(name, [])
    if not versions_as_list:
        __salt__['pkg_resource.stringify'](ret)
    # Return a string if no globbing is used, and there is one item in the
    # return dict
    if len(ret) == 1 and not pkg_glob:
        try:
            return next(six.itervalues(ret))
        except StopIteration:
            return ''
    return ret
746777
def install_from_rpm_py_package(self):
        """"""
        self._download_and_extract_rpm_py_package()

        # Find ./usr/lib64/pythonN.N/site-packages/rpm directory.
        # A binary built by same version Python with used Python is target
        # for the safe installation.

        if self.rpm.has_set_up_py_in():
            # If RPM has setup.py.in, this strict check is okay.
            # Because we can still install from the source.
            py_dir_name = 'python{0}.{1}'.format(
                          sys.version_info[0], sys.version_info[1])
        else:
            # If RPM does not have setup.py.in such as CentOS6,
            # Only way to install is by different Python's RPM package.
            py_dir_name = '*'

        python_lib_dir_pattern = os.path.join(
                                'usr', '*', py_dir_name, 'site-packages')
        rpm_dir_pattern = os.path.join(python_lib_dir_pattern, 'rpm')
        downloaded_rpm_dirs = glob.glob(rpm_dir_pattern)
        if not downloaded_rpm_dirs:
            message = 'Directory with a pattern: {0} not found.'.format(
                    rpm_dir_pattern)
            raise RpmPyPackageNotFoundError(message)
        src_rpm_dir = downloaded_rpm_dirs[0]

        # Remove rpm directory for the possible installed directories.
        for rpm_dir in self.python.python_lib_rpm_dirs:
            if os.path.isdir(rpm_dir):
                Log.debug("Remove existing rpm directory {0}".format(rpm_dir))
                shutil.rmtree(rpm_dir)

        dst_rpm_dir = self.python.python_lib_rpm_dir
        Log.debug("Copy directory from '{0}' to '{1}'".format(
                  src_rpm_dir, dst_rpm_dir))
        shutil.copytree(src_rpm_dir, dst_rpm_dir)

        file_name_pattern = 'rpm-*.egg-info'
        rpm_egg_info_pattern = os.path.join(
                               python_lib_dir_pattern, file_name_pattern)
        downloaded_rpm_egg_infos = glob.glob(rpm_egg_info_pattern)
        if downloaded_rpm_egg_infos:
            existing_rpm_egg_info_pattern = os.path.join(
                self.python.python_lib_dir, file_name_pattern)
            existing_rpm_egg_infos = glob.glob(existing_rpm_egg_info_pattern)
            for existing_rpm_egg_info in existing_rpm_egg_infos:
                Log.debug("Remove existing rpm egg info file '{0}'".format(
                          existing_rpm_egg_info))
                os.remove(existing_rpm_egg_info)

            Log.debug("Copy file from '{0}' to '{1}'".format(
                      downloaded_rpm_egg_infos[0], self.python.python_lib_dir))
            shutil.copy2(downloaded_rpm_egg_infos[0],
                         self.python.python_lib_dir)
809758
def get_version(self):
        """"""
        return mgz.const.VERSIONS[self._header.version], str(self._header.sub_version)[:5]
1312334
def info():
    
    installation_path = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))

    click.echo("colin {} {}".format(__version__, installation_path))
    click.echo("colin-cli {}\n".format(os.path.realpath(__file__)))

    # click.echo(get_version_of_the_python_package(module=conu))

    rpm_installed = is_rpm_installed()
    click.echo(get_version_msg_from_the_cmd(package_name="podman", use_rpm=rpm_installed))
    click.echo(get_version_msg_from_the_cmd(package_name="skopeo", use_rpm=rpm_installed))
    click.echo(get_version_msg_from_the_cmd(package_name="ostree",
                                            use_rpm=rpm_installed,
                                            max_lines_of_the_output=3))
446619
def package_version():
    
    version = ""
    try:
        version = pkg_resources.get_distribution('instana').version
    except pkg_resources.DistributionNotFound:
        version = 'unknown'
    finally:
        return version