Skip to content

Commit 0759bb5

Browse files
authored
added mising decode for binary input processing
1 parent 10f5c94 commit 0759bb5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

adk/ADK.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ def __init__(self, apply_func, load_func=None):
2323
self.load_func = load_func
2424
else:
2525
self.load_func = None
26-
self.apply_arity = len(apply_args)
27-
if self.apply_arity > 2 or len(apply_args) == 0:
26+
if len(apply_args) > 2 or len(apply_args) == 0:
2827
raise Exception("apply function may have between 1 and 2 parameters, not {}".format(len(apply_args)))
2928
self.apply_func = apply_func
3029
self.is_local = not os.path.exists(self.FIFO_PATH)
@@ -48,7 +47,7 @@ def format_data(self, request):
4847
if request["content_type"] in ["text", "json"]:
4948
data = request["data"]
5049
elif request["content_type"] == "binary":
51-
data = self.wrap_binary_data(request["data"])
50+
data = self.wrap_binary_data(base64.b64decode(request["data"]))
5251
else:
5352
raise Exception("Invalid content_type: {}".format(request["content_type"]))
5453
return data
@@ -120,7 +119,7 @@ def process_loop(self):
120119
try:
121120
request = json.loads(line)
122121
formatted_input = self.format_data(request)
123-
if self.load_result and self.apply_arity > 1:
122+
if self.load_result:
124123
apply_result = self.apply_func(formatted_input, self.load_result)
125124
else:
126125
apply_result = self.apply_func(formatted_input)

0 commit comments

Comments
 (0)