Skip to content
Snippets Groups Projects
Commit 7ee97d14 authored by Vincent Texier's avatar Vincent Texier
Browse files

[fix] #58 fix example request_ws2p.py after rebase

parent 74e3bf03
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ import aiohttp ...@@ -8,7 +8,7 @@ import aiohttp
import jsonschema import jsonschema
from jsonschema import ValidationError from jsonschema import ValidationError
from duniterpy.helpers import get_ws2p_challenge from duniterpy.tools import get_ws2p_challenge
from duniterpy.key import SigningKey from duniterpy.key import SigningKey
from duniterpy.api import ws2p from duniterpy.api import ws2p
...@@ -73,7 +73,7 @@ async def main(): ...@@ -73,7 +73,7 @@ async def main():
await ws.send_str(connect_message) await ws.send_str(connect_message)
# Iterate on each message received... # Iterate on each message received...
async for msg in ws: async for msg in ws: # type: aiohttp.WSMessage
# Display incoming message from peer # Display incoming message from peer
print(msg) print(msg)
...@@ -162,14 +162,14 @@ async def main(): ...@@ -162,14 +162,14 @@ async def main():
parse_text(response_str, requests.BLOCK_RESPONSE_SCHEMA) parse_text(response_str, requests.BLOCK_RESPONSE_SCHEMA)
# If valid display response # If valid display response
print("Response: " + response_str) print("Response: " + response_str)
except ValidationError as exception: except ValidationError:
# If invalid response... # If invalid response...
try: try:
# Check error response format # Check error response format
parse_text(response_str, requests.ERROR_RESPONSE_SCHEMA) parse_text(response_str, requests.ERROR_RESPONSE_SCHEMA)
# If valid, display error response # If valid, display error response
print("Error response: " + response_str) print("Error response: " + response_str)
except ValidationError as e: except ValidationError as exception:
# If invalid, display exception on response validation # If invalid, display exception on response validation
print(exception) print(exception)
...@@ -189,14 +189,14 @@ async def main(): ...@@ -189,14 +189,14 @@ async def main():
parse_text(response_str, requests.BLOCK_RESPONSE_SCHEMA) parse_text(response_str, requests.BLOCK_RESPONSE_SCHEMA)
# If valid display response # If valid display response
print("Response: " + response_str) print("Response: " + response_str)
except ValidationError as exception: except ValidationError:
# If invalid response... # If invalid response...
try: try:
# Check error response format # Check error response format
parse_text(response_str, requests.ERROR_RESPONSE_SCHEMA) parse_text(response_str, requests.ERROR_RESPONSE_SCHEMA)
# If valid, display error response # If valid, display error response
print("Error response: " + response_str) print("Error response: " + response_str)
except ValidationError as e: except ValidationError as exception:
# If invalid, display exception on response validation # If invalid, display exception on response validation
print(exception) print(exception)
...@@ -216,14 +216,14 @@ async def main(): ...@@ -216,14 +216,14 @@ async def main():
parse_text(response_str, requests.BLOCKS_RESPONSE_SCHEMA) parse_text(response_str, requests.BLOCKS_RESPONSE_SCHEMA)
# If valid display response # If valid display response
print("Response: " + response_str) print("Response: " + response_str)
except ValidationError as exception: except ValidationError:
# If invalid response... # If invalid response...
try: try:
# Check error response format # Check error response format
parse_text(response_str, requests.ERROR_RESPONSE_SCHEMA) parse_text(response_str, requests.ERROR_RESPONSE_SCHEMA)
# If valid, display error response # If valid, display error response
print("Error response: " + response_str) print("Error response: " + response_str)
except ValidationError as e: except ValidationError as exception:
# If invalid, display exception on response validation # If invalid, display exception on response validation
print(exception) print(exception)
...@@ -242,14 +242,14 @@ async def main(): ...@@ -242,14 +242,14 @@ async def main():
parse_text(response_str, requests.REQUIREMENTS_RESPONSE_SCHEMA) parse_text(response_str, requests.REQUIREMENTS_RESPONSE_SCHEMA)
# If valid display response # If valid display response
print("Response: " + response_str) print("Response: " + response_str)
except ValidationError as exception: except ValidationError:
# If invalid response... # If invalid response...
try: try:
# Check error response format # Check error response format
parse_text(response_str, requests.ERROR_RESPONSE_SCHEMA) parse_text(response_str, requests.ERROR_RESPONSE_SCHEMA)
# If valid, display error response # If valid, display error response
print("Error response: " + response_str) print("Error response: " + response_str)
except ValidationError as e: except ValidationError as exception:
# If invalid, display exception on response validation # If invalid, display exception on response validation
print(exception) print(exception)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment