Exemple #1
0
 def __init__(self, lib, **kwargs):
     self.lib = lib
     library_loader = LibraryLoader(CDLL)
     library = library_loader.LoadLibrary(lib)
     self.library = library
     for name, args in kwargs.items():
         self.__dict__[name] = CTypesFunction(library, name, *args)
Exemple #2
0
 def insertInto(self, parameterSet, myname):
     from ctypes import LibraryLoader, CDLL
     import platform
     loader = LibraryLoader(CDLL)
     ext = platform.uname()[0] == "Darwin" and "dylib" or "so"
     [loader.LoadLibrary("lib%s.%s" % (l, ext)) for l in self.libraries]
     super(LoadPrerequisiteSource, self).insertInto(parameterSet, myname)
Exemple #3
0
 def insertInto(self, parameterSet, myname):
     if "libraries_" in self.__dict__:
         from ctypes import LibraryLoader, CDLL
         import platform
         loader = LibraryLoader(CDLL)
         ext = platform.uname()[0] == "Darwin" and "dylib" or "so"
         [loader.LoadLibrary("lib%s.%s" % (l, ext)) for l in self.libraries_]
     super(_Module,self).insertInto(parameterSet,myname)
Exemple #4
0
def Haskell(library, exportPattern="{name}_export"):
    hadll = LibraryLoader(HaDLL)
    hadll.exportPattern = exportPattern

    lib = hadll.LoadLibrary(library)
    lib.hs_init(0, 0)
    yield lib
    lib.hs_exit()
    IsProcessDPIAware = windll.user32.IsProcessDPIAware
    SetProcessDPIAware = windll.user32.SetProcessDPIAware
except AttributeError:
    IsProcessDPIAware = None
    SetProcessDPIAware = None

# DpiAwareness API funcs are available only from win 8.1 and greater
# Supported types of DPI awareness described here:
# https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx
# typedef enum _Process_DPI_Awareness {
#   Process_DPI_Unaware            = 0,
#   Process_System_DPI_Aware       = 1,
#   Process_Per_Monitor_DPI_Aware  = 2
# } Process_DPI_Awareness;
try:
    shcore = windll.LoadLibrary("Shcore.dll")
    SetProcessDpiAwareness = shcore.SetProcessDpiAwareness
    GetProcessDpiAwareness = shcore.GetProcessDpiAwareness
    Process_DPI_Awareness = {
        "Process_DPI_Unaware": 0,
        "Process_System_DPI_Aware": 1,
        "Process_Per_Monitor_DPI_Aware": 2
    }
except (OSError, AttributeError):
    SetProcessDpiAwareness = None
    GetProcessDpiAwareness = None
    Process_DPI_Awareness = None

# Setup DPI awareness for the python process if any is supported
if SetProcessDpiAwareness:
    ActionLogger().log("Call SetProcessDpiAwareness")