def _clear_dll_directory(self): """ Push current Dll Directory There are two cases that can happen related to setting a dll directory. 1: Project is using different python then Desktop, in which case the desktop will set the dll directory to none for the project's python interpreter. In this case, the following code is redundant and not needed. 2: Desktop is using same python as Project. In which case we need to keep the desktop dll directory. """ if sys.platform == "win32": # This 'try' block will fail silently if user is using a different python interpreter then Desktop, # in which case it will be fine since the Desktop will have set the correct Dll folder for this # interpreter. Refer to the comments in the method's header for more information. try: import win32api # GetDLLDirectory throws an exception if none was set try: self._previous_dll_directory = win32api.GetDllDirectory( None) except StandardError: self._previous_dll_directory = None win32api.SetDllDirectory(None) except StandardError: pass
def clear_dll_directory(): """ Push current Dll Directory. There are two cases that can happen related to setting a dll directory: 1: Project is using different python then Desktop, in which case the desktop will set the dll directory to none for the project's python interpreter. In this case, the following code is redundant and not needed. 2: Desktop is using same python as Project. In which case we need to keep the desktop dll directory. """ dll_directory = None if sgtk.util.is_windows(): # This 'try' block will fail silently if user is using # a different python interpreter then Desktop, in which # case it will be fine since the Desktop will have set # the correct Dll folder for this interpreter. Refer to # the comments in the method's header for more information. try: import win32api # GetDLLDirectory throws an exception if none was set try: dll_directory = win32api.GetDllDirectory(None) except Exception: dll_directory = None win32api.SetDllDirectory(None) except Exception: pass return dll_directory
def test_dlls(self): import win32api base = win32api.GetDllDirectory() for x in os.listdir(base): if x.lower().endswith('.dll'): try: ctypes.WinDLL(str(os.path.join(base, x))) except Exception as err: self.assertTrue(False, 'Failed to load DLL %s with error: %s' % (x, err))
def test_dlls(self): import win32api base = win32api.GetDllDirectory() for x in os.listdir(base): if x.lower().endswith('.dll'): try: ctypes.WinDLL(native_string_type(os.path.join(base, x))) except Exception as err: self.assertTrue( False, 'Failed to load DLL %s with error: %s' % (x, err)) from Crypto.Cipher import AES del AES from pywintypes import error del error
def test_dlls(): import win32api base = win32api.GetDllDirectory() errors = [] for x in os.listdir(base): if x.lower().endswith('.dll'): try: ctypes.WinDLL(os.path.join(base, x)) except Exception as err: errors.append('Failed to load DLL %s with error: %s' % (x, err)) print (errors[-1]) if errors: print ('Loading %d dll(s) failed!' % len(errors)) raise SystemExit(1) print ('DLLs OK!')
def _push_dll_state(self): ''' Push current Dll Directory ''' if sys.platform == "win32": try: import win32api # GetDLLDirectory throws an exception if none was set try: self._previous_dll_directory = win32api.GetDllDirectory( None) except StandardError: self._previous_dll_directory = None win32api.SetDllDirectory(None) except StandardError: engine = sgtk.platform.current_engine() engine.log_warning( 'Could not push DllDirectory under Windows.')