Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
4c18dfef
Commit
4c18dfef
authored
Dec 21, 2020
by
oroulet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add setup.cfg, small linting
parent
eec8b64c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
20 deletions
+29
-20
asyncua/common/xmlimporter.py
asyncua/common/xmlimporter.py
+2
-2
examples/test_perf.py
examples/test_perf.py
+7
-8
setup.cfg
setup.cfg
+7
-4
test_external_server.py
test_external_server.py
+13
-6
No files found.
asyncua/common/xmlimporter.py
View file @
4c18dfef
...
...
@@ -4,7 +4,7 @@ format is the one from opc-ua specification
"""
import
logging
import
uuid
from
typing
import
Coroutine
,
Union
,
Dict
from
typing
import
Union
,
Dict
from
copy
import
copy
from
asyncua
import
ua
...
...
@@ -94,7 +94,7 @@ class XmlImporter:
from
IPython
import
embed
embed
()
async
def
_add_node_data
(
self
,
nodedata
)
->
"Node"
:
async
def
_add_node_data
(
self
,
nodedata
)
->
ua
.
NodeId
:
if
nodedata
.
nodetype
==
"UAObject"
:
node
=
await
self
.
add_object
(
nodedata
)
elif
nodedata
.
nodetype
==
"UAObjectType"
:
...
...
examples/test_perf.py
View file @
4c18dfef
...
...
@@ -2,7 +2,6 @@ import asyncio
import
time
import
sys
import
logging
import
uvloop
import
cProfile
sys
.
path
.
insert
(
0
,
".."
)
...
...
@@ -30,16 +29,16 @@ async def mymain():
async
with
server
:
while
True
:
await
asyncio
.
sleep
(
10
)
#
nb = 100000
#
start = time.time()
#
for i in range(nb):
#
await server.write_attribute_value(myvar.nodeid, ua.DataValue(i))
#
await myvar.write_value(i)
nb
=
100000
start
=
time
.
time
()
for
i
in
range
(
nb
):
await
server
.
write_attribute_value
(
myvar
.
nodeid
,
ua
.
DataValue
(
i
))
await
myvar
.
write_value
(
i
)
print
(
"
\
n
Write frequency:
\
n
"
,
nb
/
(
time
.
time
()
-
start
))
if
__name__
==
"__main__"
:
#uvloop.install()
logging
.
basicConfig
(
level
=
logging
.
WARNING
)
#
cProfile.run('asyncio.run(mymain(), debug=True)', filename="perf.cprof")
asyncio
.
run
(
mymain
())
cProfile
.
run
(
'asyncio.run(mymain(), debug=True)'
,
filename
=
"perf.cprof"
)
#
asyncio.run(mymain())
setup.cfg
View file @
4c18dfef
[aliases]
test=pytest
[flake8]
max-line-length = 120
exclude = opcua/ua/,opcua/common/event_objects.py,opcua/server/standard_address_space/standard_address_space*.py
max-line-length = 160
exclude = tests,schemas
ignore = E501
per-file-ignores =
__init__.py: F401
[pycodestyle]
max-line-length = 160
test_external_server.py
View file @
4c18dfef
...
...
@@ -2,20 +2,19 @@
Test an OPC-UA server with freeopcua python client
"""
import
sys
import
pytest
import
asyncio
import
logging
from
datetime
import
datetime
from
asyncua
import
ua
from
asyncua
import
Client
import
unittest
class
MySubHandler
:
"""
More advanced subscription client using Future, so we can wait for events in tests
"""
def
__init__
(
self
):
self
.
future
=
asyncio
.
Future
()
...
...
@@ -31,7 +30,7 @@ class MySubHandler:
class
MySubHandler2
(
object
):
def
__init__
(
self
):
self
.
results
=
[]
self
.
results
=
[]
def
datachange_notification
(
self
,
node
,
val
,
data
):
self
.
results
.
append
((
node
,
val
))
...
...
@@ -48,8 +47,8 @@ def connect(func):
func
(
self
,
client
)
finally
:
client
.
disconnect
()
return
wrapper
return
wrapper
def
test_connect_anonymous
(
self
):
...
...
@@ -57,38 +56,45 @@ def test_connect_anonymous(self):
c
.
connect
()
c
.
disconnect
()
def
FINISH_test_connect_basic256
(
self
):
c
=
Client
(
URL
)
c
.
set_security_string
(
"basic256,sign,XXXX"
)
c
.
connect
()
c
.
disconnect
()
def
test_find_servers
(
self
):
c
=
Client
(
URL
)
res
=
c
.
connect_and_find_servers
()
assert
len
(
res
)
>
0
def
test_find_endpoints
(
self
):
c
=
Client
(
URL
)
res
=
c
.
connect_and_get_server_endpoints
()
assert
len
(
res
)
>
0
# @connect
def
test_get_root
(
self
,
client
):
root
=
client
.
nodes
.
root
self
.
assertEqual
(
root
.
read_browse_name
(),
ua
.
QualifiedName
(
"Root"
,
0
))
# @connect
def
test_get_root_children
(
self
,
client
):
root
=
client
.
nodes
.
root
childs
=
root
.
get_children
()
assert
len
(
childs
)
>
2
# @connect
async
def
test_get_namespace_array
(
self
,
client
):
array
=
await
client
.
get_namespace_array
()
assert
len
(
array
)
>
0
# @connect
def
test_get_server_node
(
self
,
client
):
srv
=
client
.
nodes
.
server
...
...
@@ -96,12 +102,14 @@ def test_get_server_node(self, client):
#childs = srv.get_children()
#assert len(childs) > 4)
# @connect
def
test_browsepathtonodeid
(
self
,
client
):
root
=
client
.
nodes
.
root
node
=
root
.
get_child
([
"0:Objects"
,
"0:Server"
,
"0:ServerArray"
])
node
=
root
.
get_child
([
"0:Objects"
,
"0:Server"
,
"0:ServerArray"
])
self
.
assertEqual
(
node
.
read_browse_name
(),
ua
.
QualifiedName
(
"ServerArray"
,
0
))
# @connect
def
test_subscribe_server_time
(
self
,
client
):
msclt
=
MySubHandler
()
...
...
@@ -132,4 +140,3 @@ if __name__ == "__main__":
URL
=
sys
.
argv
[
1
]
unittest
.
main
(
verbosity
=
30
,
argv
=
sys
.
argv
[:
1
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment