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
aa1514b8
Commit
aa1514b8
authored
Jun 22, 2022
by
Alexander Schrode
Committed by
oroulet
Jun 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add strict_mode
In non strict_mode most errors are just logged an the import continues.
parent
0702ad2f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
10 deletions
+18
-10
asyncua/client/client.py
asyncua/client/client.py
+2
-2
asyncua/common/xmlimporter.py
asyncua/common/xmlimporter.py
+13
-5
asyncua/server/server.py
asyncua/server/server.py
+2
-2
asyncua/sync.py
asyncua/sync.py
+1
-1
No files found.
asyncua/client/client.py
View file @
aa1514b8
...
...
@@ -639,11 +639,11 @@ class Client:
async
def
delete_nodes
(
self
,
nodes
,
recursive
=
False
)
->
Coroutine
:
return
await
delete_nodes
(
self
.
uaclient
,
nodes
,
recursive
)
async
def
import_xml
(
self
,
path
=
None
,
xmlstring
=
None
)
->
Coroutine
:
async
def
import_xml
(
self
,
path
=
None
,
xmlstring
=
None
,
strict_mode
=
True
)
->
Coroutine
:
"""
Import nodes defined in xml
"""
importer
=
XmlImporter
(
self
)
importer
=
XmlImporter
(
self
,
strict_mode
=
strict_mode
)
return
await
importer
.
import_xml
(
path
,
xmlstring
)
async
def
export_xml
(
self
,
nodes
,
path
,
export_values
:
bool
=
False
):
...
...
asyncua/common/xmlimporter.py
View file @
aa1514b8
...
...
@@ -18,13 +18,19 @@ def _parse_version(version_string: str) -> List[int]:
return
[
int
(
v
)
for
v
in
version_string
.
split
(
'.'
)]
class
XmlImporter
:
def
__init__
(
self
,
server
):
def
__init__
(
self
,
server
,
strict_mode
=
True
):
'''
strict_mode: stop on a error, if False only a error message is logged,
but the import continues
'''
self
.
parser
=
None
self
.
server
=
server
self
.
namespaces
:
Dict
[
int
,
int
]
=
{}
# Dict[IndexInXml, IndexInServer]
self
.
aliases
:
Dict
[
str
,
ua
.
NodeId
]
=
{}
self
.
_unmigrated_aliases
:
Dict
[
str
,
str
]
=
{}
# Dict[name, nodeId string]
self
.
_unmigrated_aliases
:
Dict
[
str
,
str
]
=
{}
# Dict[name, nodeId string]
self
.
refs
=
None
self
.
strict_mode
=
strict_mode
async
def
_map_namespaces
(
self
):
"""
...
...
@@ -110,9 +116,11 @@ class XmlImporter:
for
nodedata
in
nodes_parsed
:
# self.parser:
try
:
node
=
await
self
.
_add_node_data
(
nodedata
,
no_namespace_migration
=
True
)
except
Exception
:
_logger
.
warning
(
"failure adding node %s"
,
nodedata
)
raise
raise
Exception
(
'test'
)
except
Exception
as
e
:
_logger
.
warning
(
"failure adding node %s %s"
,
nodedata
,
e
)
if
self
.
strict_mode
:
raise
nodes
.
append
(
node
)
self
.
refs
,
remaining_refs
=
[],
self
.
refs
await
self
.
_add_references
(
remaining_refs
)
...
...
asyncua/server/server.py
View file @
aa1514b8
...
...
@@ -582,11 +582,11 @@ class Server:
await
custom_t
.
add_method
(
idx
,
method
[
0
],
method
[
1
],
method
[
2
],
method
[
3
])
return
custom_t
async
def
import_xml
(
self
,
path
=
None
,
xmlstring
=
None
)
->
Coroutine
:
async
def
import_xml
(
self
,
path
=
None
,
xmlstring
=
None
,
strict_mode
=
True
)
->
Coroutine
:
"""
Import nodes defined in xml
"""
importer
=
XmlImporter
(
self
)
importer
=
XmlImporter
(
self
,
strict_mode
)
return
await
importer
.
import_xml
(
path
,
xmlstring
)
async
def
export_xml
(
self
,
nodes
,
path
,
export_values
:
bool
=
False
):
...
...
asyncua/sync.py
View file @
aa1514b8
...
...
@@ -330,7 +330,7 @@ class Server:
return
SyncNode
(
self
.
tloop
,
self
.
aio_obj
.
get_node
(
nodeid
))
@
syncmethod
def
import_xml
(
self
,
path
=
None
,
xmlstring
=
None
):
def
import_xml
(
self
,
path
=
None
,
xmlstring
=
None
,
strict_mode
=
True
):
pass
@
syncmethod
...
...
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