summaryrefslogtreecommitdiff
path: root/pyeclib/ec_iface.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyeclib/ec_iface.py')
-rw-r--r--pyeclib/ec_iface.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/pyeclib/ec_iface.py b/pyeclib/ec_iface.py
index 2b459d6..eefc370 100644
--- a/pyeclib/ec_iface.py
+++ b/pyeclib/ec_iface.py
@@ -112,6 +112,7 @@ class ECDriver(object):
self.hd = -1
self.ec_type = None
self.chksum_type = None
+ self.validate = False
for (key, value) in kwargs.items():
if key == "k":
try:
@@ -144,6 +145,9 @@ class ECDriver(object):
else:
raise ECDriverError(
"%s is not a valid checksum type for PyECLib!" % value)
+ elif key == "validate":
+ # validate if the ec type is available (runtime check)
+ self.validate = value
if self.hd == -1:
self.hd = self.m
@@ -159,7 +163,10 @@ class ECDriver(object):
m=self.m,
hd=self.hd,
ec_type=self.ec_type,
- chksum_type=self.chksum_type)
+ chksum_type=self.chksum_type,
+ validate=int(self.validate)
+ )
+
#
# Verify that the imported library implements the required functions
#
@@ -469,14 +476,21 @@ ALL_EC_TYPES = [
def _PyECLibValidECTypes():
available_ec_types = []
for _type in ALL_EC_TYPES:
+ print "== checking type %r" % _type
try:
if _type is 'shss':
- ECDriver(k=10, m=4, ec_type=_type)
+ _m = 4
else:
- ECDriver(k=10, m=5, ec_type=_type)
+ _m = 5
+ driver = ECDriver(k=10, m=_m, ec_type=_type, validate=True)
+ print "driver = %r" % driver
available_ec_types.append(_type)
except Exception:
- pass
+ import sys
+ e = sys.exc_info()[0]
+ print( "****Error: %s" % e )
+ continue
+ print available_ec_types
return available_ec_types