-
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.
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
2 changed files
with
133 additions
and
67 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
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__ = "241209" | ||
__revision__ = "241210" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -32,13 +32,13 @@ | |
err = sys.exc_info()[1] | ||
sys.exit("[ERROR] failed to import essential package: %s" % err.args[0]) | ||
|
||
# handle backward compatibility between Python 2 and 3 | ||
# handle backward compatibility between python 2 and 3 | ||
try: | ||
long # pylint: disable=used-before-assignment | ||
except: | ||
long = int | ||
|
||
# python 2's xrange is equivalent to range in Python 3 | ||
# python 2's xrange is equivalent to range in python 3 | ||
try: | ||
xrange # pylint: disable=used-before-assignment | ||
except: | ||
|
@@ -33216,19 +33216,17 @@ def updateBatInfo(): | |
): | ||
stats[sub] = "+" | ||
|
||
capacity = stats["capacity"] | ||
energy = stats["energy_now"] | ||
power = stats["power_now"] | ||
|
||
# check capacity # | ||
if stats["capacity"] == 0: | ||
if capacity == 0: | ||
return | ||
|
||
SysMgr.battery = ( | ||
stats["capacity"], | ||
( | ||
long( | ||
stats["energy_now"] / float(stats["power_now"]) * 3600 | ||
) | ||
if stats["power_now"] | ||
else 0 | ||
), | ||
capacity, | ||
(long(energy / float(power) * 3600) if power else 0), | ||
stats["status"], | ||
) | ||
except SystemExit: | ||
|
@@ -37270,7 +37268,7 @@ def convMemStat(mlist): | |
@staticmethod | ||
def getMemStatList(pid): | ||
try: | ||
mlist = SysMgr.getMemStat(SysMgr.pid) | ||
mlist = SysMgr.getMemStat(pid) | ||
return SysMgr.convMemStat(mlist) | ||
except SystemExit: | ||
sys.exit(0) | ||
|
@@ -43288,6 +43286,9 @@ def _getDesc(s, t=0): | |
# {0:1} {1:1} -q DRAWFLAME, ALLOCCNT | ||
# {0:1} {1:1} -q DRAWFLAME, ALLOCSIZE | ||
|
||
- {2:1} using report file naming format | ||
# {0:1} {1:1} -q USEREPFILENAME | ||
|
||
- Report from perfetto data | ||
# {0:1} {1:1} -I prof.data | ||
|
||
|
@@ -43423,6 +43424,9 @@ def _getDesc(s, t=0): | |
- {2:1} and report the flame graph to a specific file | ||
# {0:1} {1:1} -q DRAWFLAME | ||
|
||
- {2:1} using report file naming format | ||
# {0:1} {1:1} -q USEREPFILENAME | ||
|
||
- Report from perf data | ||
# {0:1} {1:1} -I perf.data | ||
|
||
|
@@ -50812,19 +50816,12 @@ def _handleCmd(connObj, cmd, cliProc): | |
mainCmd = cmdList[0].lower() | ||
cmdOpt = cmdList[1:] if len(cmdList) > 1 else [] | ||
|
||
# check save mode # | ||
isSaveMode = mainCmd in ("save", "saveraw", "savemin") | ||
|
||
# handle watch event # | ||
if mainCmd == "watch": | ||
SysMgr.printInfo("registered %s for event watch" % cliProc) | ||
SysMgr.eventSubList.append([cliProc, connObj]) | ||
return | ||
|
||
# backup items for worker task # | ||
localServObj = SysMgr.localServObj | ||
eventCommandList = SysMgr.eventCommandList | ||
|
||
# check the maximum number of jobs # | ||
nrMaxJob = UtilMgr.getEnvironNum("NRMAXJOB", False, 0, False) | ||
if nrMaxJob: | ||
|
@@ -50839,6 +50836,13 @@ def _handleCmd(connObj, cmd, cliProc): | |
) | ||
return | ||
|
||
# backup items before worker task creation # | ||
localServObj = SysMgr.localServObj | ||
eventCommandList = SysMgr.eventCommandList | ||
|
||
# check save mode # | ||
isSaveMode = mainCmd in ("save", "saveraw", "savemin") | ||
|
||
# create a new worker process and parent return # | ||
pid = SysMgr.createProcess() | ||
if pid > 0: | ||
|
@@ -50912,7 +50916,7 @@ def _monitorConn(connObj): | |
True, | ||
) | ||
|
||
# create a socket monitor task for disconnection # | ||
# create a socket monitor task for handling disconnection # | ||
threadObj = SysMgr.getPkg("threading") | ||
tobj = threadObj.Thread(target=_monitorConn, args=[connObj]) | ||
tobj.daemon = True | ||
|
@@ -54261,8 +54265,18 @@ def updateTimer(interval=None): | |
def makeOutPath(func): | ||
if not SysMgr.outPath: | ||
SysMgr.outPath = "." | ||
SysMgr.updateOutPath() | ||
SysMgr.outPath = SysMgr.inputFile | ||
|
||
# use report file naming # | ||
if "USEREPFILENAME" in SysMgr.environList and os.path.isdir( | ||
SysMgr.outPath | ||
): | ||
SysMgr.updateNrRun(SysMgr.outPath) | ||
cmd = sys.argv[1] if len(sys.argv) > 1 else None | ||
SysMgr.setReportPath(SysMgr.outPath, sys.argv[1], "PROF") | ||
else: | ||
SysMgr.updateOutPath() | ||
SysMgr.outPath = SysMgr.inputFile | ||
|
||
if SysMgr.inputParam: | ||
return SysMgr.inputParam | ||
else: | ||
|
@@ -54283,24 +54297,23 @@ def setReportPath(outPath, cmd, event="CUSTOM"): | |
for p in pathList[1:]: | ||
SysMgr.addEnvironVar("DUPOUTPATH", p.strip()) | ||
|
||
isTargetDir = True | ||
|
||
# fixed path # | ||
if outPath: | ||
isdir = os.path.isdir(outPath) | ||
outPathStr = outPath.rstrip("(") + "/" if isdir else "" | ||
outPathStr = outPath.rstrip("/") + "/" if isdir else "" | ||
SysMgr.printInfo("set output path to '%s'" % outPathStr) | ||
|
||
# dir # | ||
if isdir: | ||
targetDir = outPath | ||
# file # | ||
else: | ||
isTargetDir = False | ||
targetDir = "." | ||
SysMgr.outPath = outPath | ||
return | ||
# no output # | ||
elif not SysMgr.outPath: | ||
SysMgr.printErr("no output path") | ||
SysMgr.printErr("no output path for report") | ||
return | ||
# /tmp # | ||
elif SysMgr.outPath == SysMgr.nullPath: | ||
|
@@ -54313,15 +54326,14 @@ def setReportPath(outPath, cmd, event="CUSTOM"): | |
targetDir = os.path.dirname(SysMgr.outPath) | ||
|
||
# set output path # | ||
if isTargetDir: | ||
SysMgr.outPath = "%s/guider_%08d_%08d_%s_%s_%s.out" % ( | ||
targetDir, | ||
SysMgr.nrRun, | ||
SysMgr.nrReport, | ||
event, | ||
cmd, | ||
timeinfo, | ||
) | ||
SysMgr.outPath = "%s/guider_%08d_%08d_%s_%s_%s.out" % ( | ||
targetDir, | ||
SysMgr.nrRun, | ||
SysMgr.nrReport, | ||
event, | ||
cmd, | ||
timeinfo, | ||
) | ||
|
||
@staticmethod | ||
def updateOutPath(): | ||
|
@@ -56719,7 +56731,14 @@ def parseCommonOption(option, value): | |
) | ||
sys.exit(-1) | ||
|
||
SysMgr.origOutPath = SysMgr.outPath = os.path.normpath(value) | ||
# use report file naming # | ||
if "USEREPFILENAME" in SysMgr.environList and os.path.isdir(value): | ||
SysMgr.updateNrRun(value) | ||
cmd = sys.argv[1] if len(sys.argv) > 1 else None | ||
SysMgr.setReportPath(value, sys.argv[1]) | ||
else: | ||
SysMgr.outPath = os.path.normpath(value) | ||
SysMgr.origOutPath = SysMgr.outPath | ||
|
||
elif option == "s": | ||
if not SysMgr.isKillMode(): | ||
|
@@ -59719,10 +59738,22 @@ def _waitThreshold(pids, cond, timing, target, sig=False): | |
sys.exit(-1) | ||
pid = pids[0] | ||
|
||
# convert threshold # | ||
if cond.startswith("+"): | ||
rss = SysMgr.getMemStatList(pid)["rss"] | ||
cond = UtilMgr.convUnit2Size(cond[1:]) + rss | ||
else: | ||
cond = UtilMgr.convUnit2Size(cond) | ||
|
||
# wait for threshold # | ||
SysMgr.waitThreshold( | ||
pid, rss=True, cond=cond, bt=True, purpose=timing | ||
) | ||
try: | ||
SysMgr.waitThreshold( | ||
pid, rss=True, cond=cond, bt=True, purpose=timing | ||
) | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
SysMgr.printErr("canceled to wait for threshold", True) | ||
|
||
# recover variables # | ||
SysMgr.environList.pop("TARGETCMD") | ||
|
@@ -60043,17 +60074,16 @@ def _waitThreshold(pids, cond, timing, target, sig=False): | |
startRss = SysMgr.environList.get("STARTRSS") | ||
if startRss: | ||
try: | ||
startRss = UtilMgr.convUnit2Size(startRss[0]) | ||
_waitThreshold(pids, startRss[0], "START", target, True) | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
_printErr( | ||
"failed to get RSS(%s) for start" % startRss[0], True | ||
"failed to wait for RSS(%s) for start" % startRss[0], | ||
True, | ||
) | ||
sys.exit(-1) | ||
|
||
_waitThreshold(pids, startRss, "START", target, True) | ||
|
||
# set timer # | ||
try: | ||
timer = SysMgr.getOption("R") | ||
|
@@ -60135,17 +60165,16 @@ def _waitTask(pid): | |
stopRss = SysMgr.environList.get("STOPRSS") | ||
if stopRss: | ||
try: | ||
stopRss = UtilMgr.convUnit2Size(stopRss[0]) | ||
_waitThreshold(pids, stopRss[0], "STOP", target) | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
_printErr( | ||
"failed to get RSS(%s) for stop" % stopRss[0], True | ||
"failed to wait for RSS(%s) for stop" % stopRss[0], | ||
True, | ||
) | ||
sys.exit(-1) | ||
|
||
_waitThreshold(pids, stopRss, "STOP", target) | ||
|
||
# wait for events # | ||
if javaTarget: | ||
# wait for task termination # | ||
|
@@ -60392,9 +60421,14 @@ def _waitThreshold(pids, cond, timing, sig=False): | |
pid = pids[0] | ||
|
||
# wait for threshold # | ||
SysMgr.waitThreshold( | ||
pid, cpu=True, cond=cond, bt=True, purpose=timing | ||
) | ||
try: | ||
SysMgr.waitThreshold( | ||
pid, cpu=True, cond=cond, bt=True, purpose=timing | ||
) | ||
except SystemExit: | ||
sys.exit(0) | ||
except: | ||
SysMgr.printErr("canceled to wait for threshold", True) | ||
|
||
# set normal handler for profiling # | ||
if sig: | ||
|
@@ -156851,7 +156885,9 @@ def _checkResource(item): | |
# send events to watching tasks # | ||
eventSubList = list(SysMgr.eventSubList) | ||
SysMgr.eventSubList = [] | ||
pubInfo = UtilMgr.convDict2Str({ename: comval}, pretty=False).rstrip() | ||
pubInfo = UtilMgr.convDict2Str({ename: comval}, pretty=False) | ||
if pubInfo: | ||
pubInfo = pubInfo.rstrip() | ||
for winfo in eventSubList: | ||
cliProc, netObj = winfo | ||
ret = SysMgr.sendEvents( | ||
|