代码拉取完成,页面将自动刷新
#!/usr/bin/env python3.6
import os
from os.path import join as pjoin
import pandas as pd
from utils import common as c
from paths import st_stat_dir
def regenerate_st_stat(pairs: list, cache: str) -> None:
st_targets = [
'system\.cpu\.(ipc::0)',
]
matrix = {}
for p in pairs:
matrix[p] = c.get_stats(pjoin(st_stat_dir, p, 'stats.txt'),
st_targets, re_targets=True)
df = pd.DataFrame(matrix)
df.to_csv(cache, index=True)
df = pd.read_csv(cache, index_col=0)
print(df)
def make_st_stat_cache() -> None:
pairs = c.pairs(st_stat_dir, False)
stat_files = [pjoin(st_stat_dir, x, 'stats.txt') \
for x in pairs]
stat_timestamps = [os.path.getmtime(x) for x in stat_files]
newest = max(stat_timestamps)
script = os.path.realpath(__file__)
cache_file = pjoin(os.path.dirname(script), 'cache_st_stat.txt')
if not os.path.isfile(cache_file) or \
newest > os.path.getmtime(cache_file) or \
os.path.getmtime(script) > os.path.getmtime(cache_file):
regenerate_st_stat(pairs, cache_file)
if __name__ == '__main__':
make_st_stat_cache()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。