-
-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathwin_utils.py
More file actions
19 lines (15 loc) · 634 Bytes
/
win_utils.py
File metadata and controls
19 lines (15 loc) · 634 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pathlib
import win32api
from tests import SENTRY_VERSION
def check_binary_version(binary_path: pathlib.Path):
if not binary_path.exists():
return
info = win32api.GetFileVersionInfo(str(binary_path), "\\")
ms = info["FileVersionMS"]
ls = info["FileVersionLS"]
file_version = (ms >> 16, ms & 0xFFFF, ls >> 16, ls & 0xFFFF)
file_version = f"{file_version[0]}.{file_version[1]}.{file_version[2]}"
if SENTRY_VERSION != file_version:
raise RuntimeError(
f"Binary {binary_path.parts[-1]} has a different version ({file_version}) than expected ({SENTRY_VERSION})."
)