本文整理汇总了Python中pyeclib.ec_iface.ECDriver.decode方法的典型用法代码示例。如果您正苦于以下问题:Python ECDriver.decode方法的具体用法?Python ECDriver.decode怎么用?Python ECDriver.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyeclib.ec_iface.ECDriver
的用法示例。
在下文中一共展示了ECDriver.decode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestNullDriver
# 需要导入模块: from pyeclib.ec_iface import ECDriver [as 别名]
# 或者: from pyeclib.ec_iface.ECDriver import decode [as 别名]
class TestNullDriver(unittest.TestCase):
def setUp(self):
self.null_driver = ECDriver(library_import_str="pyeclib.core.ECNullDriver", k=8, m=2)
def tearDown(self):
pass
def test_null_driver(self):
self.null_driver.encode("")
self.null_driver.decode([])
示例2: Eraser
# 需要导入模块: from pyeclib.ec_iface import ECDriver [as 别名]
# 或者: from pyeclib.ec_iface.ECDriver import decode [as 别名]
class Eraser(object):
"""A wrapper for pyeclib erasure coding driver (ECDriver)"""
def __init__(self, k=8, m=2, ec_type="liberasurecode_rs_vand"):
self.k = k
self.m = m
self.ec_type = ec_type
if EC_TYPE == "pylonghair":
self.driver = PylonghairDriver(k=EC_K, m=EC_M, ec_type=EC_TYPE)
elif EC_TYPE == "striping" or EC_TYPE == "bypass":
self.driver = ECStripingDriver(k=EC_K, m=0, hd=None)
else:
self.driver = ECDriver(k=EC_K, m=EC_M, ec_type=EC_TYPE)
def encode(self, data):
"""Encode a string of bytes in flattened string of byte strips"""
raw_strips = self.driver.encode(data)
strips = []
for raw_strip in raw_strips:
strip = Strip()
strip.data = raw_strip
strips.append(strip)
return strips
def decode(self, playcloud_strips):
"""Decode byte strips in a string of bytes"""
strips = convert_strips_to_bytes_list(playcloud_strips)
return self.driver.decode(strips)
示例3: decode
# 需要导入模块: from pyeclib.ec_iface import ECDriver [as 别名]
# 或者: from pyeclib.ec_iface.ECDriver import decode [as 别名]
def decode(k,m,base_filename_to_decode,ec_type) :
#print("k = %d, m = %d" % (k, m))
#print("ec_type = %s" % ec_type)
home = expanduser("~")
Disk_base_dir = home + '/Disk'
key_list = base_filename_to_decode.split('.')
jdecoder_types = ["reed_sol_van", "reed_sol_r6_op","cauchy_orig","cauchy_good","liberation","blaum_roth","liber8tion"]
if ec_type in jdecoder_types :
print "Decoding started "
jdecoder = ctypes.CDLL('/home/raven/Downloads/Jerasure-master/Examples/jdecoder.so')
key = key_list[0]
decoded_data = str(jdecoder.decode(key,Disk_base_dir))
print "decoded data = ", decoded_data
else :
ec_driver = ECDriver(k = k, m = m, ec_type = ec_type)
fragment_list = []
i = 0
while i <=k :
if os.path.exists(Disk_base_dir + "/" + "Disk_" + str(i)) :
curr_dir = Disk_base_dir + "/" + "Disk_" + str(i)
if i == 0 :
if os.path.exists(curr_dir + "/" + base_filename_to_decode) :
with open(curr_dir + "/" + base_filename_to_decode,'rb') as fp :
decoded_data = fp.read()
fp.close()
return decoded_data
else :
if os.path.exists(curr_dir + "/" + base_filename_to_decode + "_fragment_" + str(i)) :
with open(curr_dir + "/" + base_filename_to_decode + "_fragment_" + str(i),'rb') as fp :
fragment = fp.read()
fp.close()
fragment_list.append(fragment)
i = i + 1
if len(fragment_list) < k :
return -1 # Not enough fragments to decode
else :
decoded_data = ec_driver.decode(fragment_list)
return decoded_data
示例4: open
# 需要导入模块: from pyeclib.ec_iface import ECDriver [as 别名]
# 或者: from pyeclib.ec_iface.ECDriver import decode [as 别名]
from pyeclib.ec_iface import ECDriver
import pickle
from random import shuffle
if __name__ == '__main__':
with open('results.pkl', 'rb') as f:
results_dict = pickle.load(f)
for key, frags in results_dict.items():
k, m = key
driver = ECDriver(ec_type='jerasure_rs_vand', k=k, m=m)
for num in range(10):
shuffle(frags)
assert 'a'*100 == driver.decode(
frags[:k], force_metadata_checks=True)
print '%s passed' % str(key)
示例5: print
# 需要导入模块: from pyeclib.ec_iface import ECDriver [as 别名]
# 或者: from pyeclib.ec_iface.ECDriver import decode [as 别名]
parser = argparse.ArgumentParser(description='Decoder for PyECLib.')
parser.add_argument('k', type=int, help='number of data elements')
parser.add_argument('m', type=int, help='number of parity elements')
parser.add_argument('ec_type', help='EC algorithm used')
parser.add_argument('fragments', metavar='fragment', nargs='+',
help='fragments to decode')
parser.add_argument('filename', help='output file')
args = parser.parse_args()
print("k = %d, m = %d" % (args.k, args.m))
print("ec_type = %s" % args.ec_type)
print("fragments = %s" % args.fragments)
print("filename = %s" % args.filename)
ec_driver = ECDriver(k=args.k, m=args.m, ec_type=args.ec_type)
fragment_list = []
# read fragments
for fragment in args.fragments:
with open(("%s" % fragment), "rb") as fp:
fragment_list.append(fp.read())
# decode
decoded_file = ec_driver.decode(fragment_list)
# write
with open("%s.decoded" % args.filename, "wb") as fp:
fp.write(decoded_file)