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

pefile replacement #76

Open
axet opened this issue Sep 14, 2024 · 1 comment
Open

pefile replacement #76

axet opened this issue Sep 14, 2024 · 1 comment
Labels
enhancement New feature or request WIP Currently being worked on

Comments

@axet
Copy link

axet commented Sep 14, 2024

Allow to work on linux (get rid of win32api)

diff --git a/sac_lib/get_file_version.py b/sac_lib/get_file_version.py
index da53c0b..cacc012 100644
--- a/sac_lib/get_file_version.py
+++ b/sac_lib/get_file_version.py
@@ -1,5 +1,5 @@
-import win32api
+import pefile
 
 def GetFileVersion(filename: str) -> str:
-    fileInfos = win32api.GetFileVersionInfo(filename, "\\")
-    return "%d.%d.%d.%d" % (fileInfos['FileVersionMS'] / 65536, fileInfos['FileVersionMS'] % 65536, fileInfos['FileVersionLS'] / 65536, fileInfos['FileVersionLS'] % 65536)
\ No newline at end of file
+    fileInfos = pefile.PE(filename).VS_FIXEDFILEINFO
+    return "%d.%d.%d.%d" % (fileInfos.FileVersionMS >> 16, fileInfos.FileVersionMS & 0xFFFF, fileInfos.FileVersionLS >> 16, fileInfos.FileVersionLS & 0xFFFF)
@BigBoiCJ
Copy link
Owner

Thanks! I'll test it and update if it works :)

How did you get all these colors? That's nice, didn't know that was possible to be shown in a github issue message

(and again for the really late response)

@BigBoiCJ BigBoiCJ added enhancement New feature or request WIP Currently being worked on labels Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request WIP Currently being worked on
Projects
None yet
Development

No branches or pull requests

2 participants