summaryrefslogtreecommitdiffstats
path: root/sploit/util.py
blob: b0572a0126512d5e499a06e53a2f32f9b8375611 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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