-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
topdiff: Ignore invalid files and sort valid files
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
1 changed file
with
28 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
__credits__ = "Peace Lee" | ||
__license__ = "GPLv2" | ||
__version__ = "3.9.8" | ||
__revision__ = "240902" | ||
__revision__ = "240903" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -115829,6 +115829,7 @@ def _getProcName(pinfo): | |
# save all stats in a file # | ||
validFlist.append(lfile) | ||
statFileList[lfile] = gstats | ||
idx = len(validFlist) - 1 | ||
|
||
# define proc usage # | ||
cpuProcUsage = gstats["cpuProcUsage"] | ||
|
@@ -115931,7 +115932,7 @@ def _getProcName(pinfo): | |
if idx > 0: | ||
targetList = {} | ||
prevIdx = 0 if fromStart else idx - 1 | ||
prevList = flist[prevIdx] | ||
prevList = validFlist[prevIdx] | ||
if not prevList in statFileList: | ||
continue | ||
prevProcList = statFileList[prevList]["cpuProcUsage"] | ||
|
@@ -115950,7 +115951,7 @@ def _getProcName(pinfo): | |
pass | ||
|
||
# set diff to the union list if this file is latest one # | ||
if nrFiles == 1: | ||
if len(validFlist) == 1: | ||
cpuStats = statFileList[lfile]["cpuProcUsage"] | ||
for pname in list(unionCpuList): | ||
try: | ||
|
@@ -115959,11 +115960,11 @@ def _getProcName(pinfo): | |
sys.exit(0) | ||
except: | ||
pass | ||
elif idx == nrFiles - 1 and nrFiles > 1: | ||
prevProcList = statFileList.get(flist[-2], {}).get( | ||
else: | ||
prevProcList = statFileList.get(validFlist[-2], {}).get( | ||
"cpuProcUsage", {} | ||
) | ||
lastProcList = statFileList.get(flist[-1], {}).get( | ||
lastProcList = statFileList.get(validFlist[-1], {}).get( | ||
"cpuProcUsage", {} | ||
) | ||
for pname, value in unionCpuList.items(): | ||
|
@@ -116048,7 +116049,7 @@ def _getProcName(pinfo): | |
if idx > 0: | ||
targetList = {} | ||
prevIdx = 0 if fromStart else idx - 1 | ||
prevList = flist[prevIdx] | ||
prevList = validFlist[prevIdx] | ||
if not prevList in statFileList: | ||
continue | ||
prevProcList = statFileList[prevList]["gpuProcUsage"] | ||
|
@@ -116067,7 +116068,7 @@ def _getProcName(pinfo): | |
pass | ||
|
||
# set diff to the union list if this file is latest one # | ||
if nrFiles == 1: | ||
if len(validFlist) == 1: | ||
gpuStats = statFileList[lfile]["gpuProcUsage"] | ||
for pname in list(unionGpuList): | ||
try: | ||
|
@@ -116076,7 +116077,7 @@ def _getProcName(pinfo): | |
sys.exit(0) | ||
except: | ||
pass | ||
elif idx == nrFiles and nrFiles > 1: | ||
else: | ||
unionGpuList[pname] = value["diff"] | ||
|
||
# remove * characters # | ||
|
@@ -116152,7 +116153,7 @@ def _getProcName(pinfo): | |
if idx > 0: | ||
targetList = {} | ||
prevIdx = 0 if fromStart else idx - 1 | ||
prevList = flist[prevIdx] | ||
prevList = validFlist[prevIdx] | ||
if not prevList in statFileList: | ||
continue | ||
prevProcList = statFileList[prevList]["memProcUsage"] | ||
|
@@ -116176,7 +116177,7 @@ def _getProcName(pinfo): | |
continue | ||
|
||
# set diff to the union list if this file is latest one # | ||
if nrFiles == 1: | ||
if len(validFlist) == 1: | ||
memStats = statFileList[lfile]["memProcUsage"] | ||
for pname in list(unionRssList): | ||
try: | ||
|
@@ -116185,11 +116186,11 @@ def _getProcName(pinfo): | |
sys.exit(0) | ||
except: | ||
pass | ||
elif idx == nrFiles - 1 and nrFiles > 1: | ||
prevProcList = statFileList.get(flist[-2], {}).get( | ||
else: | ||
prevProcList = statFileList.get(validFlist[-2], {}).get( | ||
"memProcUsage", {} | ||
) | ||
lastProcList = statFileList.get(flist[-1], {}).get( | ||
lastProcList = statFileList.get(validFlist[-1], {}).get( | ||
"memProcUsage", {} | ||
) | ||
for pname, value in unionRssList.items(): | ||
|
@@ -116280,7 +116281,7 @@ def _getProcName(pinfo): | |
# save diff itself # | ||
if idx > 0: | ||
prevIdx = 0 if fromStart else idx - 1 | ||
prevSdList = statFileList[flist[prevIdx]].get( | ||
prevSdList = statFileList[validFlist[prevIdx]].get( | ||
"systemdInfo", {} | ||
) | ||
prevSdList = prevSdList.get("BOOT", {}).get(unit, {}) | ||
|
@@ -116297,7 +116298,7 @@ def _getProcName(pinfo): | |
stats["initDiff"] = stats["actDiff"] | ||
|
||
# set diff to the union list if this file is latest one # | ||
if nrFiles == 1: | ||
if len(validFlist) == 1: | ||
for uname in list(unionSdList): | ||
try: | ||
unionSdList[uname] = bootStat[uname][sortStd] | ||
|
@@ -116316,7 +116317,7 @@ def _getProcName(pinfo): | |
sys.exit(0) | ||
except: | ||
pass | ||
elif idx == nrFiles - 1: | ||
else: | ||
if prevSdList.get("activating"): | ||
unionSdList[unit] = bootStat[unit][sortStd] | ||
else: | ||
|
@@ -116911,12 +116912,14 @@ def _printer(string): | |
continue | ||
|
||
actDiff = ( | ||
("%5.1f" % float(sdList[pname])) if sdList[pname] else "-" | ||
convNum(float(sdList[pname]), True, 1) | ||
if sdList[pname] | ||
else "-" | ||
) | ||
if pname in prevSdList: | ||
initDiff = float(value) - float(prevSdList[pname]) | ||
if initDiff: | ||
initDiffStr = "%5.1f" % round(initDiff, 2) | ||
initDiffStr = convNum(initDiff, True, 1) | ||
if initDiff > 0: | ||
initDiff = convColor(initDiffStr, "RED") | ||
elif initDiff < 0: | ||
|
@@ -116984,7 +116987,7 @@ def _printer(string): | |
start = sdUnitStat["activating"] | ||
if start: | ||
if "startDiff" in sdUnitStat: | ||
startDiff = "%5.1f" % round(sdUnitStat["startDiff"], 2) | ||
startDiff = convNum(sdUnitStat["startDiff"], True, 1) | ||
if sdUnitStat["startDiff"] > 0: | ||
startDiff = convColor(startDiff, "RED") | ||
elif sdUnitStat["startDiff"] < 0: | ||
|
@@ -116996,7 +116999,7 @@ def _printer(string): | |
startDiff = "-" | ||
actDiff = sdUnitStat["actDiff"] | ||
if "initDiff" in sdUnitStat: | ||
initDiff = "%5.1f" % round(sdUnitStat["initDiff"], 2) | ||
initDiff = convNum(sdUnitStat["initDiff"], True, 1) | ||
if sdUnitStat["initDiff"] > 0: | ||
initDiff = convColor(initDiff, "RED") | ||
elif sdUnitStat["initDiff"] < 0: | ||
|
@@ -117006,10 +117009,10 @@ def _printer(string): | |
totalerr += abs(sdUnitStat["initDiff"]) | ||
else: | ||
initDiff = "-" | ||
diff = "%5.1f(%5s)/%5.1f(%5s) |" % ( | ||
start, | ||
diff = "%5s(%5s)/%5s(%5s) |" % ( | ||
convNum(start, True, 1), | ||
startDiff, | ||
actDiff, | ||
convNum(actDiff, True, 1), | ||
initDiff, | ||
) | ||
else: | ||
|
@@ -133405,7 +133408,7 @@ def _initData(): | |
_printMenu(" Leak Hint ") | ||
TaskAnalyzer.printLeakHint() | ||
|
||
# print D-Bus info # | ||
# print systemd info using D-Bus # | ||
if "PRINTSYSTEMD" in SysMgr.environList: | ||
origJsonEnable = SysMgr.jsonEnable | ||
SysMgr.jsonEnable = True | ||
|