info.py 文件源码

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

项目:nsls-ii-tools 作者: NSLS-II 项目源码 文件源码
def get_sys_info():
    """Display info on system and output as nice HTML"""
    spacer = "<tr><td>&nbsp;</td><td>&nbsp;</td></tr>"

    html = '<h3>System Information for {}</h3>'.format(platform.node())
    html += '<table>'

    html += '<tr><td align="left">Python Executable</td>'
    html += '<td>{}</td></tr>'.format(sys.executable)
    html += '<tr><td>Kernel PID</td><td>{}</td></tr>'.format(
        psutil.Process().pid)

    mem = psutil.virtual_memory()
    html += '<tr><td>Total System Memory</td>'
    html += '<td>{:.4} Mb</td></td>'.format(mem.total/1024**3)
    html += '<tr><td>Total Memory Used</td>'
    html += '<td>{:.4} Mb</td></td>'.format(mem.used/1024**3)
    html += '<tr><td>Total Memory Free</td>'
    html += '<td>{:.4} Mb</td></td>'.format(mem.free/1024**3)

    html += '<tr><td>Number of CPU Cores</td><td>{}</td></tr>'.format(
        psutil.cpu_count())
    html += '<tr><td>Current CPU Load</td><td>{} %</td></tr>'.format(
        psutil.cpu_percent(1, False))

    html += '</table>'
    return HTML(html)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号