mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Added a custom fix for Libloader with changes made by @jmdaweb #273
This commit is contained in:
parent
c8d83ed9e7
commit
e5b33160e0
@ -3,6 +3,7 @@
|
||||
from __future__ import absolute_import
|
||||
import sys
|
||||
from . import fix_arrow # A few new locales for Three languages in arrow.
|
||||
from . import fix_libloader # Regenerates comcache properly.
|
||||
from . import fix_urllib3_warnings # Avoiding some SSL warnings related to Twython.
|
||||
from . import fix_win32com
|
||||
from . import fix_requests #fix cacert.pem location for TWBlue binary copies
|
||||
@ -11,6 +12,7 @@ def setup():
|
||||
if hasattr(sys, "frozen"):
|
||||
fix_win32com.fix()
|
||||
fix_requests.fix(True)
|
||||
fix_libloader.fix()
|
||||
else:
|
||||
fix_requests.fix(False)
|
||||
fix_urllib3_warnings.fix()
|
36
src/fixes/fix_libloader.py
Normal file
36
src/fixes/fix_libloader.py
Normal file
@ -0,0 +1,36 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import win32com
|
||||
import paths
|
||||
win32com.__gen_path__=paths.com_path()
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.join(win32com.__gen_path__, "."))
|
||||
from win32com.client import gencache
|
||||
from pywintypes import com_error
|
||||
from libloader import com
|
||||
|
||||
fixed=False
|
||||
|
||||
def patched_getmodule(modname):
|
||||
mod=__import__(modname)
|
||||
return sys.modules[modname]
|
||||
|
||||
def load_com(*names):
|
||||
global fixed
|
||||
if fixed==False:
|
||||
gencache._GetModule=patched_getmodule
|
||||
com.prepare_gencache()
|
||||
fixed=True
|
||||
result = None
|
||||
for name in names:
|
||||
try:
|
||||
result = gencache.EnsureDispatch(name)
|
||||
break
|
||||
except com_error:
|
||||
continue
|
||||
if result is None:
|
||||
raise com_error("Unable to load any of the provided com objects.")
|
||||
return result
|
||||
|
||||
def fix():
|
||||
com.load_com = load_com
|
Loading…
Reference in New Issue
Block a user