Skip to content

Commit

Permalink
ipatests: add function for getting python package version on remote host
Browse files Browse the repository at this point in the history
  • Loading branch information
sorlov-rh committed Apr 29, 2020
1 parent c7684f9 commit 53921df
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ipatests/pytest_ipa/integration/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from pipes import quote
import configparser
from contextlib import contextmanager
from pkg_resources import parse_version
from pkg_resources import parse_version, get_distribution

import dns
from ldif import LDIFWriter
Expand Down Expand Up @@ -2172,3 +2172,11 @@ def configure_ipa_client_for_ad_trust(client):
' dns_lookup_kdc = .+', ' dns_lookup_kdc = true', krb5conf)
assert n == 1
client.put_file_contents(paths.KRB5_CONF, krb5conf)


def get_python_package_version(host, package):
script = (
'import pkg_resources; '
'print(pkg_resources.get_distribution("{}").version)'.format(package))
result = host.run_command(['python3', '-c', script])
return parse_version(result.stdout_text.strip())

0 comments on commit 53921df

Please sign in to comment.