From 6b81c77d2297b883bd603bd9354e1bf17720664d Mon Sep 17 00:00:00 2001 From: Willi Ballenthin Date: Thu, 13 Jul 2023 11:45:53 +0200 Subject: [PATCH] profile-time: workaround for flake8-encodings bug https://github.com/python-formate/flake8-encodings/issues/35 --- scripts/profile-time.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/scripts/profile-time.py b/scripts/profile-time.py index b6c48683..9acd60ff 100644 --- a/scripts/profile-time.py +++ b/scripts/profile-time.py @@ -58,22 +58,16 @@ import capa.features.freeze logger = logging.getLogger("capa.profile") +def subshell(cmd): + return subprocess.run(cmd, shell=True, capture_output=True, text=True).stdout.strip() + + def main(argv=None): if argv is None: argv = sys.argv[1:] - label = subprocess.run( - "git show --pretty=oneline --abbrev-commit | head -n 1", shell=True, capture_output=True, text=True - ).stdout.strip() - is_dirty = ( - subprocess.run( - "git status | grep 'modified: ' | grep -v 'rules' | grep -v 'tests/data'", - shell=True, - capture_output=True, - text=True, - ).stdout - != "" - ) + label = subshell("git show --pretty=oneline --abbrev-commit | head -n 1").strip() + is_dirty = subshell("git status | grep 'modified: ' | grep -v 'rules' | grep -v 'tests/data'") != "" if is_dirty: label += " (dirty)"