-
Notifications
You must be signed in to change notification settings - Fork 2
/
create_enrollement_input.py
33 lines (29 loc) · 1 KB
/
create_enrollement_input.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import argparse
import json
import base64
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-a", "--record1", required=True,
help="")
ap.add_argument("-b", "--record2", required=True,
help="")
ap.add_argument("-c", "--record3", required=True,
help="")
args = vars(ap.parse_args())
records = []
binary_records = []
records.append(args["record1"])
records.append(args["record2"])
records.append(args["record3"])
for path in records :
with open(path, 'rb') as binary_file:
binary_file_data = binary_file.read()
base64_encoded_data = base64.b64encode(binary_file_data)
#binary_records.append(base64_encoded_data)
base64_message = base64_encoded_data.decode('utf-8')
binary_records.append(base64_message)
#print(base64_message)
output = {'record1':binary_records[0],'record2':binary_records[1],'record3':binary_records[2]}
#print(output)
with open('enrollement.json', 'w+') as outfile:
json.dump(output, outfile)