def get_remote_installed_packages(ip_address):
'''
This method queries a remote python installation about the installed packages.
All necessary information is extracted from ~/.artemisrc
:param address: Ip address of remote server
:return:
'''
python_executable = get_artemis_config_value(section=ip_address, option="python")
function = "%s -c 'import pip; import json; print json.dumps({i.key: i.version for i in pip.get_installed_distributions() })' "%python_executable
ssh_conn = get_ssh_connection(ip_address)
stdin , stdout, stderr = ssh_conn.exec_command(function)
err = stderr.read()
if err:
msg="Quering %s python installation at %s sent a message on stderr. If you are confident that the error can be ignored, catch this RuntimeError" \
"accordingly. The error is: %s"%(ip_address, python_executable, err)
raise RuntimeError(msg)
installed_packages = json.loads(stdout.read())
ssh_conn.close()
return installed_packages
评论列表
文章目录