More precise exceptions
This commit is contained in:
parent
a181da3632
commit
079326bc03
|
@ -47,12 +47,12 @@ class WorkProver(threading.Thread):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.availableSolvers["fast"] = fastsolver.FastSolver(codePath)
|
self.availableSolvers["fast"] = fastsolver.FastSolver(codePath)
|
||||||
except:
|
except fastsolver.FastSolverError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.availableSolvers["gpu"] = gpusolver.GPUSolver(codePath, GPUVendors)
|
self.availableSolvers["gpu"] = gpusolver.GPUSolver(codePath, GPUVendors)
|
||||||
except:
|
except gpusolver.GPUSolverError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -4,6 +4,9 @@ import platform
|
||||||
import subprocess
|
import subprocess
|
||||||
import ctypes
|
import ctypes
|
||||||
|
|
||||||
|
class FastSolverError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def loadFastSolver(codePath):
|
def loadFastSolver(codePath):
|
||||||
if hasattr(sys, "winver"):
|
if hasattr(sys, "winver"):
|
||||||
suffix = "-32"
|
suffix = "-32"
|
||||||
|
@ -13,7 +16,10 @@ def loadFastSolver(codePath):
|
||||||
|
|
||||||
path = os.path.join(codePath, "fastsolver/libfastsolver{}.dll".format(suffix))
|
path = os.path.join(codePath, "fastsolver/libfastsolver{}.dll".format(suffix))
|
||||||
|
|
||||||
return ctypes.WinDLL(path)
|
try:
|
||||||
|
return ctypes.WinDLL(path)
|
||||||
|
except:
|
||||||
|
raise FastSolverError()
|
||||||
|
|
||||||
makePath = os.path.join(codePath, "fastsolver")
|
makePath = os.path.join(codePath, "fastsolver")
|
||||||
path = os.path.join(codePath, "fastsolver/libfastsolver.so")
|
path = os.path.join(codePath, "fastsolver/libfastsolver.so")
|
||||||
|
@ -21,12 +27,15 @@ def loadFastSolver(codePath):
|
||||||
try:
|
try:
|
||||||
return ctypes.CDLL(path)
|
return ctypes.CDLL(path)
|
||||||
except:
|
except:
|
||||||
if not hasattr(sys, "frozen"):
|
if hasattr(sys, "frozen"):
|
||||||
|
raise FastSolverError()
|
||||||
|
|
||||||
|
try:
|
||||||
subprocess.call(["make", "-C", makePath])
|
subprocess.call(["make", "-C", makePath])
|
||||||
|
|
||||||
return ctypes.CDLL(path)
|
return ctypes.CDLL(path)
|
||||||
else:
|
except:
|
||||||
raise Exception()
|
raise FastSolverError()
|
||||||
|
|
||||||
class FastSolver(object):
|
class FastSolver(object):
|
||||||
def __init__(self, codePath):
|
def __init__(self, codePath):
|
||||||
|
|
|
@ -14,8 +14,11 @@ class GPUSolver(object):
|
||||||
def __init__(self, codePath, vendors = None):
|
def __init__(self, codePath, vendors = None):
|
||||||
global pyopencl, numpy
|
global pyopencl, numpy
|
||||||
|
|
||||||
import pyopencl
|
try:
|
||||||
import numpy
|
import pyopencl
|
||||||
|
import numpy
|
||||||
|
except ImportError:
|
||||||
|
raise GPUSolverError()
|
||||||
|
|
||||||
device = None
|
device = None
|
||||||
|
|
||||||
|
@ -30,7 +33,7 @@ class GPUSolver(object):
|
||||||
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise Exception()
|
raise GPUSolverError()
|
||||||
|
|
||||||
context = pyopencl.Context(devices = [device])
|
context = pyopencl.Context(devices = [device])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user