Make Enemizer Check a bit more multithreading resilient.

This commit is contained in:
Fabian Dill 2020-08-12 08:48:29 +02:00
parent 4849d811cd
commit 7eb419154b
1 changed files with 29 additions and 25 deletions

10
Rom.py
View File

@ -10,6 +10,7 @@ import random
import struct
import sys
import subprocess
import threading
from BaseClasses import CollectionState, ShopType, Region, Location
from Dungeons import dungeon_music_addresses
@ -146,7 +147,11 @@ def read_rom(stream) -> bytearray:
return buffer
check_lock = threading.Lock()
def check_enemizer(enemizercli):
with check_lock:
if getattr(check_enemizer, "done", None):
return
if not os.path.exists(enemizercli) and not os.path.exists(enemizercli + ".exe"):
@ -156,17 +161,16 @@ def check_enemizer(enemizercli):
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")
pythoncom.CoInitialize()
ver_parser = Dispatch('Scripting.FileSystemObject')
info = ver_parser.GetFileVersion(library)
if info == 'No Version Information Available':
info = None
if info != 'No Version Information Available':
version = tuple(int(part) for part in info.split("."))
if version < (6, 1, 0, 222):
raise Exception(