Beispiel #1
0
def new_test_db(
    path: Path,
    num_of_blocks: int,
    seed: bytes,
    empty_sub_slots: int,
    normalized_to_identity_cc_eos: bool = False,  # CC_EOS,
    normalized_to_identity_icc_eos: bool = False,  # ICC_EOS
    normalized_to_identity_cc_sp: bool = False,  # CC_SP,
    normalized_to_identity_cc_ip: bool = False,  # CC_IP
):
    print(f"create {path} with {num_of_blocks} blocks with ")
    blocks: List[FullBlock] = bt.get_consecutive_blocks(
        num_of_blocks,
        seed=seed,
        skip_slots=empty_sub_slots,
        normalized_to_identity_cc_eos=normalized_to_identity_cc_eos,
        normalized_to_identity_icc_eos=normalized_to_identity_icc_eos,
        normalized_to_identity_cc_sp=normalized_to_identity_cc_sp,
        normalized_to_identity_cc_ip=normalized_to_identity_cc_ip,
    )
    block_bytes_list: List[bytes] = []
    for block in blocks:
        block_bytes_list.append(bytes(block))
    bytes_fn = pickle.dumps(block_bytes_list)
    path.write_bytes(bytes_fn)
    return blocks
Beispiel #2
0
def new_test_db(path: Path, num_of_blocks: int, seed: bytes):
    print(f"create {path} with {num_of_blocks} blocks")
    blocks: List[FullBlock] = bt.get_consecutive_blocks(num_of_blocks, seed=seed)
    block_bytes_list: List[bytes] = []
    for block in blocks:
        block_bytes_list.append(bytes(block))
    bytes_fn = pickle.dumps(block_bytes_list)
    path.write_bytes(bytes_fn)
    return blocks
Beispiel #3
0
def save_to_local(pics):
    print(f'Saving to local files...')
    for data, file_name in pics:
        dir_name = settings.local_pict_dir_name
        if not os.path.exists(dir_name):
            os.mkdir(dir_name)
        path = Path(dir_name + '/' + file_name)
        path.write_bytes(data)
    print(f'Saving completed.')
Beispiel #4
0
 def download_from_aws(self, dest=Path('/var/media/')):
     path = dest / self.pdf.name
     data = self.pdf.file.read()
     path.parent.mkdir(0o775, True, True)
     path.write_bytes(data)
Beispiel #5
0
 def download_from_aws(self, dest=Path('/var/media/')):
     path = dest / self.pdf.name
     data = self.pdf.file.read()
     path.parent.mkdir(0o775, True, True)
     path.write_bytes(data)