-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from ferrouswheel/master
Misc proto/grpc fixes
- Loading branch information
Showing
2 changed files
with
21 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,20 +71,24 @@ def _transform_call_params(self, params): | |
""" | ||
rez = {} | ||
for k, v in params.items(): | ||
# k = modifier1@[email protected]@k_final | ||
k_split = k.split("@") | ||
k_final = k_split[-1] | ||
k_mods = k_split[:-1] | ||
for m in k_mods: | ||
if (m == "file"): | ||
with open(v, 'rb') as f: | ||
v = f.read() | ||
elif (m == "b64encode"): | ||
v = base64.b64encode(v) | ||
elif (m == "b64decode"): | ||
v = base64.b64decode(v) | ||
else: | ||
raise Exception("Unknow modifier ('%s') in call parameters. Possible modifiers: file, b64encode, b64decode"%m) | ||
if isinstance(v, dict): | ||
v = self._transform_call_params(v) | ||
k_final = k | ||
else: | ||
# k = modifier1@[email protected]@k_final | ||
k_split = k.split("@") | ||
k_final = k_split[-1] | ||
k_mods = k_split[:-1] | ||
for m in k_mods: | ||
if (m == "file"): | ||
with open(v, 'rb') as f: | ||
v = f.read() | ||
elif (m == "b64encode"): | ||
v = base64.b64encode(v) | ||
elif (m == "b64decode"): | ||
v = base64.b64decode(v) | ||
else: | ||
raise Exception("Unknown modifier ('%s') in call parameters. Possible modifiers: file, b64encode, b64decode"%m) | ||
rez[k_final] = v | ||
return rez | ||
|
||
|
@@ -110,7 +114,6 @@ def _call_server_via_grpc_channel(self, grpc_channel, nonce, amount, params, ser | |
("snet-payment-channel-nonce", str(nonce) ), | ||
("snet-payment-channel-amount", str(amount) ), | ||
("snet-payment-channel-signature-bin", bytes(signature))] | ||
|
||
response = call_fn(request, metadata=metadata) | ||
return response | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters