Skip to content

Commit

Permalink
draw: Support return outputs in JSON format
Browse files Browse the repository at this point in the history
Signed-off-by: iipeace <iipeace5@gmail.com>
  • Loading branch information
iipeace committed Sep 1, 2024
1 parent eeff27c commit eb87e89
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions guider/guider.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__credits__ = "Peace Lee"
__license__ = "GPLv2"
__version__ = "3.9.8"
__revision__ = "240831"
__revision__ = "240901"
__maintainer__ = "Peace Lee"
__email__ = "iipeace5@gmail.com"
__repository__ = "https://github.com/iipeace/guider"
Expand Down Expand Up @@ -56292,24 +56292,9 @@ def isDrawMode():
return False
elif sys.argv[1] == "draw" or orig:
return True
elif len(SysMgr.origArgs) > 1 and SysMgr.origArgs[1] in (
"drawbitmap",
"drawcpu",
"drawdelay",
"drawflame",
"drawhist",
"drawio",
"drawleak",
"drawmem",
"drawpri",
"drawrss",
"drawstack",
"drawtime",
"drawviolin",
"drawvss",
):
return True
elif SysMgr.isDrawAvgMode():
elif len(SysMgr.origArgs) > 1 and SysMgr.origArgs[
1
] in SysMgr.getCmdList().get("visual", {}):
return True
else:
SysMgr.drawMode = orig
Expand Down Expand Up @@ -117410,6 +117395,7 @@ def __init__(self, fpath=None, onlyInstance=False):
ret = drawFunc(SysMgr.inputParam)
resDict[",".join(SysMgr.inputParam)] = ret

# print output results #
if SysMgr.jsonEnable:
SysMgr.printPipe(
UtilMgr.convDict2Str(
Expand Down Expand Up @@ -120962,6 +120948,8 @@ def _printMemUsage(signum=None, frame=None):
for item in removeItems:
graphStats.pop(name, None)

resDict = {}

# draw graphs #
try:
if graphStats and not onlyChart:
Expand All @@ -120972,28 +120960,33 @@ def _printMemUsage(signum=None, frame=None):
outFd=outFd,
logEvents=logEvents,
)
resDict["graph"] = ret
except SystemExit:
sys.exit(0)
except:
SysMgr.printErr("failed to draw graph", True)
return
return resDict

# draw charts #
try:
if chartStats and not onlyGraph:
# draw detailed memory chart #
ret = self.drawProcChart(chartStats, logFile, outFile=outFile)
resDict["memchart"] = ret

# draw system memory chart #
if graphStats and SysMgr.pssEnable:
ret = self.drawSmemChart(
graphStats, logFile, outFile=outFile
)
resDict["smemchart"] = ret
except SystemExit:
sys.exit(0)
except:
SysMgr.printErr("failed to draw chart", True)
return
return resDict

return resDict

def drawSmemChart(self, data, logFile, outFile=None):
# pylint: disable=undefined-variable
Expand Down Expand Up @@ -124731,7 +124724,7 @@ def drawStack(
sys.exit(-1)

# save to file #
TaskAnalyzer.saveImage(fileName, "stack_plot", outFile=outFile)
return TaskAnalyzer.saveImage(fileName, "stack_plot", outFile=outFile)

@staticmethod
def drawViolin(
Expand Down Expand Up @@ -125189,7 +125182,7 @@ def _applyTickLabel(items, nameList, xname, yname, index, ax):
break

# save to file #
TaskAnalyzer.saveImage(fileName, "violin_plot", outFile=outFile)
return TaskAnalyzer.saveImage(fileName, "violin_plot", outFile=outFile)

def drawAvgGraph(self, graphStats, logFile, outFile=None, outFd=None):
def _getTextAlign(idx, timeline):
Expand Down Expand Up @@ -125978,6 +125971,8 @@ def saveImage(logFile, itype="", outFile=None, fd=None):
SysMgr.printStat(
"wrote %s image into '%s'%s" % (itype, fname, fsize)
)

return fname
except SystemExit:
sys.exit(0)
except:
Expand Down

0 comments on commit eb87e89

Please sign in to comment.