Make Enemizer Check a bit more multithreading resilient.
This commit is contained in:
parent
4849d811cd
commit
7eb419154b
10
Rom.py
10
Rom.py
|
@ -10,6 +10,7 @@ import random
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import threading
|
||||||
|
|
||||||
from BaseClasses import CollectionState, ShopType, Region, Location
|
from BaseClasses import CollectionState, ShopType, Region, Location
|
||||||
from Dungeons import dungeon_music_addresses
|
from Dungeons import dungeon_music_addresses
|
||||||
|
@ -146,7 +147,11 @@ def read_rom(stream) -> bytearray:
|
||||||
return buffer
|
return buffer
|
||||||
|
|
||||||
|
|
||||||
|
check_lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
def check_enemizer(enemizercli):
|
def check_enemizer(enemizercli):
|
||||||
|
with check_lock:
|
||||||
if getattr(check_enemizer, "done", None):
|
if getattr(check_enemizer, "done", None):
|
||||||
return
|
return
|
||||||
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"):
|
||||||
|
@ -156,17 +161,16 @@ def check_enemizer(enemizercli):
|
||||||
try:
|
try:
|
||||||
import pythoncom
|
import pythoncom
|
||||||
from win32com.client import Dispatch
|
from win32com.client import Dispatch
|
||||||
|
pythoncom.CoInitialize()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logging.info("Could not check Enemizer Version info as pywin32 bindings are missing.")
|
logging.info("Could not check Enemizer Version info as pywin32 bindings are missing.")
|
||||||
else:
|
else:
|
||||||
# version info is saved on the lib, for some reason
|
# version info is saved on the lib, for some reason
|
||||||
library = os.path.join(os.path.dirname(enemizercli), "EnemizerLibrary.dll")
|
library = os.path.join(os.path.dirname(enemizercli), "EnemizerLibrary.dll")
|
||||||
pythoncom.CoInitialize()
|
|
||||||
ver_parser = Dispatch('Scripting.FileSystemObject')
|
ver_parser = Dispatch('Scripting.FileSystemObject')
|
||||||
info = ver_parser.GetFileVersion(library)
|
info = ver_parser.GetFileVersion(library)
|
||||||
|
|
||||||
if info == 'No Version Information Available':
|
if info != 'No Version Information Available':
|
||||||
info = None
|
|
||||||
version = tuple(int(part) for part in info.split("."))
|
version = tuple(int(part) for part in info.split("."))
|
||||||
if version < (6, 1, 0, 222):
|
if version < (6, 1, 0, 222):
|
||||||
raise Exception(
|
raise Exception(
|
||||||
|
|
Loading…
Reference in New Issue