Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main: unhandled exception while processing InvalidRule exception #1169

Closed
mike-hunhoff opened this issue Sep 9, 2022 · 0 comments · Fixed by #1170
Closed

main: unhandled exception while processing InvalidRule exception #1169

mike-hunhoff opened this issue Sep 9, 2022 · 0 comments · Fixed by #1170
Labels
bug Something isn't working

Comments

@mike-hunhoff
Copy link
Collaborator

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 1197, in <module>
  File "main.py", line 1038, in main
  File "version.py", line 5, in get_major_version
ValueError: invalid literal for int() with base 10: 'v4'
[1808] Failed to execute script 'main' due to unhandled exception!

likely cause is

version = (
subprocess.check_output(["git", "describe", "--always", "--tags", "--long"])
.decode("utf-8")
.strip()
.replace("tags/", "")
)
# when invoking pyinstaller from the project root, this gets run from the project root.
with open("./capa/version.py", "r", encoding="utf-8") as f:
lines = f.read()
# version.py contains the version string and other helper functions
# here we manually replace the version value substring with the result of the above git output
VERSION_DEF = "__version__ = "
s = lines.index(VERSION_DEF)
e = s + len(VERSION_DEF)
off_rest_file = e + lines[e:].index("\n")
lines = lines[s:e] + f'"{version}"' + lines[off_rest_file:]
with open("./capa/version.py", "w", encoding="utf-8") as f:
f.write(lines)

output of GitHub command used above on Linux:

v4.0.1-88-g99cb5ab
@mike-hunhoff mike-hunhoff added the bug Something isn't working label Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant