diff options
author | dusoleil <howcansocksbereal@gmail.com> | 2022-03-12 19:18:28 -0500 |
---|---|---|
committer | dusoleil <howcansocksbereal@gmail.com> | 2022-03-13 23:27:30 -0400 |
commit | 509a8cfcadcca94d336fe08be897f62a721079d2 (patch) | |
tree | 0b729aaf72aebfd9d57deea07192e82fc225ad9b /sploit/util.py | |
parent | fc1c413bc6b0054cc9c079dbdd2e74eefd75557a (diff) | |
download | nsploit-509a8cfcadcca94d336fe08be897f62a721079d2.tar.gz nsploit-509a8cfcadcca94d336fe08be897f62a721079d2.zip |
sploit: cache results of external commands
rather than cacheing ELF instantiations, just cache the results of
external commands
Signed-off-by: dusoleil <howcansocksbereal@gmail.com>
Diffstat (limited to 'sploit/util.py')
-rw-r--r-- | sploit/util.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sploit/util.py b/sploit/util.py new file mode 100644 index 0000000..b0572a0 --- /dev/null +++ b/sploit/util.py @@ -0,0 +1,18 @@ +from subprocess import run + +def run_cmd(cmd): + return run(cmd,capture_output=True).stdout.decode('utf-8').split('\n')[:-1] + +__RUN_CACHE__ = {} +def run_cmd_cached(cmd): + key = ''.join(cmd) + if key in __RUN_CACHE__: + print('cache hit') + return __RUN_CACHE__[key] + else: + print('cache miss') + result = run_cmd(cmd) + __RUN_CACHE__[key] = result + return result + + |