virtualenv.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:artemis 作者: QUVA-Lab 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号