profile-time: workaround for flake8-encodings bug

https://github.com/python-formate/flake8-encodings/issues/35
This commit is contained in:
Willi Ballenthin
2023-07-13 11:45:53 +02:00
parent 9e9f120c80
commit 6b81c77d22

View File

@@ -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)"