-
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.
ctop: Add include and except family attributes
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
2 changed files
with
82 additions
and
51 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__ = "231103" | ||
__revision__ = "231104" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -7189,6 +7189,19 @@ def printSyscalls(systable): | |
|
||
sys.exit("%s\ntotal: %s" % (bufstring, len(systable))) | ||
|
||
@staticmethod | ||
def isValidStrAll(string, key=None, inc=False, ignCap=False): | ||
if not string or not key: | ||
return False | ||
|
||
final = True | ||
for item in key: | ||
if not UtilMgr.isValidStr(string, [item], inc, ignCap): | ||
final = False | ||
break | ||
|
||
return final | ||
|
||
@staticmethod | ||
def isValidStr(string, key=None, inc=False, ignCap=False): | ||
if not string: | ||
|
@@ -7218,14 +7231,14 @@ def isValidStr(string, key=None, inc=False, ignCap=False): | |
if cond == "*": | ||
return True | ||
elif ( | ||
cond.startswith("*") | ||
and cond.endswith("*") | ||
cond[0] == "*" | ||
and cond[-1] == "*" | ||
and cond.strip("*") in string | ||
): | ||
return True | ||
elif cond.startswith("*") and string.endswith(cond[1:]): | ||
elif cond[0] == "*" and string.endswith(cond[1:]): | ||
return True | ||
elif cond.endswith("*") and string.startswith(cond[:-1]): | ||
elif cond[-1] == "*" and string.startswith(cond[:-1]): | ||
return True | ||
elif cond == string: | ||
return True | ||
|
@@ -137039,23 +137052,39 @@ def _checkThreshold(cond): | |
if not type(cond) is dict: | ||
return False | ||
|
||
# check apply attribute # | ||
if cond.get("apply") != "true": | ||
return False | ||
# check except attribute # | ||
elif "except" in cond: | ||
def _getTarget(addval, elist): | ||
if "task" in addval: | ||
pid = next(iter(addval["task"])) | ||
etarget = addval["task"][pid]["comm"].lstrip("*") | ||
elif "dev" in addval: | ||
etarget = addval["dev"] | ||
else: | ||
etarget = None | ||
elist = elist if type(elist) is list else [elist] | ||
return etarget, elist | ||
|
||
elist = cond["except"] | ||
if etarget and UtilMgr.isValidStr( | ||
etarget, elist if type(elist) is list else [elist] | ||
): | ||
# check apply attribute # | ||
if cond.get("apply") != "true": | ||
return False | ||
# check exceptOR attribute # | ||
elif "exceptOR" in cond: | ||
etarget, elist = _getTarget(addval, cond["exceptOR"]) | ||
if etarget and UtilMgr.isValidStr(etarget, elist): | ||
return False | ||
# check exceptAND attribute # | ||
elif "exceptAND" in cond: | ||
etarget, elist = _getTarget(addval, cond["exceptAND"]) | ||
if etarget and UtilMgr.isValidStrAll(etarget, elist): | ||
return False | ||
# check includeOR attribute # | ||
elif "includeOR" in cond: | ||
etarget, elist = _getTarget(addval, cond["includeOR"]) | ||
if etarget and not UtilMgr.isValidStr(etarget, elist): | ||
return False | ||
# check includeAND attribute # | ||
elif "includeAND" in cond: | ||
etarget, elist = _getTarget(addval, cond["includeAND"]) | ||
if etarget and not UtilMgr.isValidStrAll(etarget, elist): | ||
return False | ||
|
||
# check oneshot flag # | ||
|