Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
7ee97d14
Commit
7ee97d14
authored
5 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#58
fix example request_ws2p.py after rebase
parent
74e3bf03
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/request_ws2p.py
+10
-10
10 additions, 10 deletions
examples/request_ws2p.py
with
10 additions
and
10 deletions
examples/request_ws2p.py
+
10
−
10
View file @
7ee97d14
...
@@ -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.
helper
s
import
get_ws2p_challenge
from
duniterpy.
tool
s
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
e
xception
:
# 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
e
xception
:
# 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
e
xception
:
# 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
e
xception
:
# If invalid, display exception on response validation
# If invalid, display exception on response validation
print
(
exception
)
print
(
exception
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment