Make Enemizer version check work on all platforms
This commit is contained in:
parent
9d9a13dd1d
commit
ecf5c505d3
31
Rom.py
31
Rom.py
|
@ -168,30 +168,29 @@ def check_enemizer(enemizercli):
|
||||||
if not os.path.exists(enemizercli) and not os.path.exists(enemizercli + ".exe"):
|
if not os.path.exists(enemizercli) and not os.path.exists(enemizercli + ".exe"):
|
||||||
raise Exception(f"Enemizer not found at {enemizercli}, please install it."
|
raise Exception(f"Enemizer not found at {enemizercli}, please install it."
|
||||||
f"Such as https://github.com/Ijwu/Enemizer/releases")
|
f"Such as https://github.com/Ijwu/Enemizer/releases")
|
||||||
if sys.platform == "win32":
|
|
||||||
# the win32api calls appear to not be threadsafe, which is the reason for the lock
|
|
||||||
with check_lock:
|
with check_lock:
|
||||||
# some time may have passed since the lock was acquired, as such a quick re-check doesn't hurt
|
# some time may have passed since the lock was acquired, as such a quick re-check doesn't hurt
|
||||||
if getattr(check_enemizer, "done", None):
|
if getattr(check_enemizer, "done", None):
|
||||||
return
|
return
|
||||||
try:
|
|
||||||
import pythoncom
|
|
||||||
from win32com.client import Dispatch
|
|
||||||
pythoncom.CoInitialize()
|
|
||||||
except ImportError:
|
|
||||||
logging.info("Could not check Enemizer Version info as pywin32 bindings are missing.")
|
|
||||||
else:
|
|
||||||
# version info is saved on the lib, for some reason
|
|
||||||
library = os.path.join(os.path.dirname(enemizercli), "EnemizerLibrary.dll")
|
|
||||||
ver_parser = Dispatch('Scripting.FileSystemObject')
|
|
||||||
info = ver_parser.GetFileVersion(library)
|
|
||||||
|
|
||||||
if info != 'No Version Information Available':
|
# version info is saved on the lib, for some reason
|
||||||
version = tuple(int(part) for part in info.split("."))
|
library_info = os.path.join(os.path.dirname(enemizercli), "EnemizerCLI.Core.deps.json")
|
||||||
if version < (6, 1, 0, 222):
|
with open(library_info) as f:
|
||||||
|
info = json.load(f)
|
||||||
|
|
||||||
|
for lib in info["libraries"]:
|
||||||
|
if lib.startswith("EnemizerLibrary/"):
|
||||||
|
version = lib.split("/")[-1]
|
||||||
|
version = tuple(int(element) for element in version.split("."))
|
||||||
|
logging.info(version)
|
||||||
|
if version < (6, 2, 0):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"Enemizer found at {enemizercli} is outdated ({info}), please update your Enemizer. "
|
f"Enemizer found at {enemizercli} is outdated ({info}), please update your Enemizer. "
|
||||||
f"Such as https://github.com/Ijwu/Enemizer/releases")
|
f"Such as https://github.com/Ijwu/Enemizer/releases")
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise Exception(f"Could not find Enemizer library version information in {library_info}")
|
||||||
|
|
||||||
check_enemizer.done = True
|
check_enemizer.done = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue