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
10a2272a
Commit
10a2272a
authored
May 01, 2023
by
Olivier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix ruff warnings (mostly automatic)
parent
0a646446
Changes
46
Hide whitespace changes
Inline
Side-by-side
Showing
46 changed files
with
49 additions
and
67 deletions
+49
-67
asyncua/client/ha/reconciliator.py
asyncua/client/ha/reconciliator.py
+1
-1
asyncua/common/callback.py
asyncua/common/callback.py
+4
-4
asyncua/common/statemachine.py
asyncua/common/statemachine.py
+1
-1
asyncua/common/subscription.py
asyncua/common/subscription.py
+1
-1
asyncua/common/xmlexporter.py
asyncua/common/xmlexporter.py
+1
-1
asyncua/crypto/security_policies.py
asyncua/crypto/security_policies.py
+2
-2
asyncua/crypto/uacrypto.py
asyncua/crypto/uacrypto.py
+4
-4
asyncua/server/event_generator.py
asyncua/server/event_generator.py
+1
-1
asyncua/server/internal_server.py
asyncua/server/internal_server.py
+1
-1
asyncua/server/internal_session.py
asyncua/server/internal_session.py
+1
-1
asyncua/tools.py
asyncua/tools.py
+3
-4
asyncua/ua/object_ids.py
asyncua/ua/object_ids.py
+0
-1
asyncua/ua/status_codes.py
asyncua/ua/status_codes.py
+0
-1
asyncua/ua/ua_binary.py
asyncua/ua/ua_binary.py
+3
-3
asyncua/ua/uaprotocol_hand.py
asyncua/ua/uaprotocol_hand.py
+1
-2
asyncua/ua/uatypes.py
asyncua/ua/uatypes.py
+1
-1
examples/client-custom-structures-and-enums.py
examples/client-custom-structures-and-enums.py
+1
-1
examples/client-subscription.py
examples/client-subscription.py
+0
-1
examples/client-with-encryption.py
examples/client-with-encryption.py
+1
-1
examples/client_play_with_type_definition.py
examples/client_play_with_type_definition.py
+2
-2
examples/client_read-custom_structures.py
examples/client_read-custom_structures.py
+0
-2
examples/client_to_demo-this.com.py
examples/client_to_demo-this.com.py
+0
-1
examples/client_to_kepware.py
examples/client_to_kepware.py
+1
-1
examples/client_to_prosys.py
examples/client_to_prosys.py
+1
-1
examples/client_to_uanet_alarm_conditions.py
examples/client_to_uanet_alarm_conditions.py
+1
-1
examples/finitestatemachine-example.py
examples/finitestatemachine-example.py
+1
-1
examples/perf-client.py
examples/perf-client.py
+0
-2
examples/server-callback.py
examples/server-callback.py
+1
-1
examples/server-custom-object.py
examples/server-custom-object.py
+0
-1
examples/server-enums-before-1.04.py
examples/server-enums-before-1.04.py
+0
-1
examples/server-events.py
examples/server-events.py
+1
-1
examples/server-instantiate-object.py
examples/server-instantiate-object.py
+1
-1
examples/server-limits.py
examples/server-limits.py
+1
-1
examples/server-robotics.py
examples/server-robotics.py
+1
-2
examples/server-virtual-network.py
examples/server-virtual-network.py
+1
-1
examples/server-with-encryption.py
examples/server-with-encryption.py
+0
-1
examples/server-xmlexporter.py
examples/server-xmlexporter.py
+1
-1
examples/statemachine-example.py
examples/statemachine-example.py
+1
-1
tests/conftest.py
tests/conftest.py
+1
-1
tests/test_common.py
tests/test_common.py
+1
-1
tests/test_connections.py
tests/test_connections.py
+0
-1
tests/test_crypto_connect.py
tests/test_crypto_connect.py
+1
-1
tests/test_server.py
tests/test_server.py
+2
-2
tests/test_subscriptions.py
tests/test_subscriptions.py
+0
-1
tests/test_unit.py
tests/test_unit.py
+2
-2
tests/util_enum_struct.py
tests/util_enum_struct.py
+1
-3
No files found.
asyncua/client/ha/reconciliator.py
View file @
10a2272a
...
...
@@ -7,7 +7,7 @@ from collections import defaultdict
from
dataclasses
import
astuple
from
enum
import
Enum
from
functools
import
partial
from
typing
import
TYPE_CHECKING
,
Dict
,
Set
,
Union
,
List
,
Optional
from
typing
import
TYPE_CHECKING
,
Dict
,
Set
,
Union
,
List
from
sortedcontainers
import
SortedDict
# type: ignore
from
asyncua
import
ua
,
Client
from
pickle
import
PicklingError
...
...
asyncua/common/callback.py
View file @
10a2272a
"""
server side implementation of callback event
server side implementation of callback event
"""
from
collections
import
OrderedDict
...
...
@@ -84,9 +84,9 @@ class CallbackService(object):
if
not
listener
:
del
self
.
_listeners
[
eventName
]
else
:
for
p
,
l
in
self
.
_listeners
[
eventName
].
items
():
if
l
is
listener
:
self
.
_listeners
[
eventName
].
pop
(
p
)
for
name
,
mylistener
in
self
.
_listeners
[
eventName
].
items
():
if
mylistener
is
listener
:
self
.
_listeners
[
eventName
].
pop
(
name
)
return
def
addSubscriber
(
self
,
subscriber
):
...
...
asyncua/common/statemachine.py
View file @
10a2272a
...
...
@@ -239,7 +239,7 @@ class StateMachine(object):
'''
if
not
isinstance
(
state
,
State
):
raise
ValueError
(
f"Statemachine:
{
self
.
_name
}
-> state:
{
state
}
is not a instance of StateMachine.State class"
)
if
not
state_type
in
[
ua
.
NodeId
(
2309
,
0
),
ua
.
NodeId
(
2307
,
0
),
ua
.
NodeId
(
15109
,
0
)]:
if
state_type
not
in
[
ua
.
NodeId
(
2309
,
0
),
ua
.
NodeId
(
2307
,
0
),
ua
.
NodeId
(
15109
,
0
)]:
# unknown state type!
raise
ValueError
(
f"Statemachine:
{
self
.
_name
}
-> state_type:
{
state_type
}
is not in list: [ua.NodeId(2309, 0),ua.NodeId(2307, 0),ua.NodeId(15109,0)]"
)
if
not
state
.
name
:
...
...
asyncua/common/subscription.py
View file @
10a2272a
...
...
@@ -242,7 +242,7 @@ class Subscription:
"""
sourcenode
=
Node
(
self
.
server
,
sourcenode
)
if
evfilter
is
None
:
if
not
type
(
evtypes
)
in
(
list
,
tuple
)
and
evtypes
==
ua
.
ObjectIds
.
BaseEventType
:
if
type
(
evtypes
)
not
in
(
list
,
tuple
)
and
evtypes
==
ua
.
ObjectIds
.
BaseEventType
:
# Remove where clause for base event type, for servers that have problems with long WhereClauses.
# Also because BaseEventType wants every event we can ommit it. Issue: #1205
where_clause_generation
=
False
...
...
asyncua/common/xmlexporter.py
View file @
10a2272a
...
...
@@ -8,7 +8,7 @@ import functools
from
collections
import
OrderedDict
import
xml.etree.ElementTree
as
Et
import
base64
from
dataclasses
import
fields
,
is_dataclass
from
dataclasses
import
is_dataclass
from
enum
import
Enum
from
asyncua
import
ua
...
...
asyncua/crypto/security_policies.py
View file @
10a2272a
...
...
@@ -180,7 +180,7 @@ class Cryptography(CryptographyNone):
if
not
self
.
use_prev_key
:
self
.
Verifier
.
verify
(
data
,
sig
)
else
:
_logger
.
debug
(
f
"Message verification fallback: trying with previous secure channel key"
)
_logger
.
debug
(
"Message verification fallback: trying with previous secure channel key"
)
self
.
Prev_Verifier
.
verify
(
data
,
sig
)
def
encrypt
(
self
,
data
):
...
...
@@ -209,7 +209,7 @@ class Cryptography(CryptographyNone):
self
.
Prev_Decryptor
=
None
self
.
Prev_Verifier
.
reset
()
self
.
Prev_Verifier
=
None
_logger
.
debug
(
f
"Expired secure_channel keys removed"
)
_logger
.
debug
(
"Expired secure_channel keys removed"
)
@
property
def
use_prev_key
(
self
):
...
...
asyncua/crypto/uacrypto.py
View file @
10a2272a
...
...
@@ -14,14 +14,14 @@ from cryptography.hazmat.primitives.ciphers import algorithms
from
cryptography.hazmat.primitives.ciphers
import
modes
# We redefine InvalidSignature as part of this module. Do not remove this line.
from
cryptography.exceptions
import
InvalidSignature
# noqa
from
cryptography.exceptions
import
InvalidSignature
# noqa: F811
from
dataclasses
import
dataclass
import
logging
_logger
=
logging
.
getLogger
(
__name__
)
class
InvalidSignature
(
Exception
):
class
InvalidSignature
(
Exception
):
# noqa: F811
pass
...
...
@@ -281,12 +281,12 @@ def check_certificate(cert: x509.Certificate, application_uri: str, hostname: Op
try
:
san
=
cert
.
extensions
.
get_extension_for_class
(
x509
.
SubjectAlternativeName
)
san_uri
=
san
.
value
.
get_values_for_type
(
x509
.
UniformResourceIdentifier
)
if
not
(
application_uri
in
san_uri
)
:
if
application_uri
not
in
san_uri
:
_logger
.
error
(
f'certificate does not contain the application uri (
{
application_uri
}
). Most applications will reject a connection without it.'
)
err
=
True
if
hostname
is
not
None
:
san_dns_names
=
san
.
value
.
get_values_for_type
(
x509
.
DNSName
)
if
not
(
hostname
in
san_dns_names
)
:
if
hostname
not
in
san_dns_names
:
_logger
.
error
(
f'certificate does not contain the hostname in DNSNames
{
hostname
}
. Some applications will check this.'
)
err
=
True
except
x509
.
ExtensionNotFound
:
...
...
asyncua/server/event_generator.py
View file @
10a2272a
...
...
@@ -64,7 +64,7 @@ class EventGenerator:
ref
.
TargetNodeClass
=
ua
.
NodeClass
.
ObjectType
ref
.
TargetNodeId
=
self
.
event
.
EventType
refs
.
append
(
ref
)
results
=
await
self
.
isession
.
add_references
(
refs
)
await
self
.
isession
.
add_references
(
refs
)
# result.StatusCode.check()
self
.
emitting_node
=
emitting_node
...
...
asyncua/server/internal_server.py
View file @
10a2272a
...
...
@@ -10,7 +10,7 @@ from struct import unpack_from
from
pathlib
import
Path
import
logging
from
urllib.parse
import
urlparse
from
typing
import
Coroutine
,
Tuple
from
typing
import
Coroutine
from
asyncua
import
ua
from
.user_managers
import
PermissiveUserManager
,
UserManager
...
...
asyncua/server/internal_session.py
View file @
10a2272a
import
logging
from
enum
import
Enum
from
typing
import
Coroutine
,
Iterable
,
Optional
,
List
,
Any
from
typing
import
Iterable
,
Optional
,
List
from
asyncua
import
ua
from
asyncua.common.session_interface
import
AbstractSession
...
...
asyncua/tools.py
View file @
10a2272a
...
...
@@ -4,7 +4,6 @@ import sys
import
argparse
from
datetime
import
datetime
,
timedelta
import
math
import
time
import
concurrent.futures
try
:
...
...
@@ -589,7 +588,7 @@ async def _uaclient():
try
:
async
with
client
:
mynode
=
await
get_node
(
client
,
args
)
await
get_node
(
client
,
args
)
except
(
OSError
,
concurrent
.
futures
.
TimeoutError
)
as
e
:
print
(
e
)
sys
.
exit
(
1
)
...
...
@@ -669,8 +668,8 @@ async def _uaserver():
await
mywritablevar
.
set_writable
()
# Set MyVariable to be writable by clients
myvar
=
await
myobj
.
add_variable
(
idx
,
"MyVariable"
,
6.7
)
myarrayvar
=
await
myobj
.
add_variable
(
idx
,
"MyVarArray"
,
[
6.7
,
7.9
])
myprop
=
await
myobj
.
add_property
(
idx
,
"MyProperty"
,
"I am a property"
)
mymethod
=
await
myobj
.
add_method
(
await
myobj
.
add_property
(
idx
,
"MyProperty"
,
"I am a property"
)
await
myobj
.
add_method
(
idx
,
"MyMethod"
,
multiply
,
...
...
asyncua/ua/object_ids.py
View file @
10a2272a
#AUTOGENERATED!!!
from enum import IntEnum
class ObjectIds:
Null = 0
asyncua/ua/status_codes.py
View file @
10a2272a
#AUTOGENERATED!!! Date: 2022-09-22 16:18:40.855698
from
asyncua.ua.uaerrors
import
UaStatusCodeError
class
StatusCodes
:
Good
=
0x00000000
...
...
asyncua/ua/ua_binary.py
View file @
10a2272a
...
...
@@ -5,7 +5,7 @@ Binary protocol specific functions and constants
import
functools
import
struct
import
logging
from
typing
import
Any
,
Callable
,
Union
from
typing
import
Any
,
Callable
import
typing
import
uuid
from
enum
import
Enum
,
IntFlag
...
...
@@ -284,7 +284,7 @@ def create_dataclass_serializer(dataclazz):
# it is possible that the type annotations also refere to classes defined in other modules.
try
:
resolved_fieldtypes
=
typing
.
get_type_hints
(
dataclazz
,
{
'ua'
:
ua
})
except
NameError
as
e
:
except
NameError
:
resolved_fieldtypes
=
typing
.
get_type_hints
(
dataclazz
)
for
f
in
data_fields
:
...
...
@@ -657,7 +657,7 @@ def _create_dataclass_deserializer(objtype):
# its possible that the type annotations also refere to classes defined in other modules.
try
:
resolved_fieldtypes
=
typing
.
get_type_hints
(
objtype
,
{
'ua'
:
ua
})
except
NameError
as
e
:
except
NameError
:
resolved_fieldtypes
=
typing
.
get_type_hints
(
objtype
)
for
field
in
fields
(
objtype
):
...
...
asyncua/ua/uaprotocol_hand.py
View file @
10a2272a
...
...
@@ -5,7 +5,6 @@ from typing import List
from
asyncua.ua
import
uaprotocol_auto
as
auto
from
asyncua.ua
import
uatypes
from
asyncua.common
import
utils
from
asyncua.ua.uatypes
import
AccessLevel
OPC_TCP_SCHEME
=
'opc.tcp'
...
...
@@ -82,7 +81,7 @@ class AsymmetricAlgorithmHeader:
ReceiverCertificateThumbPrint
:
uatypes
.
ByteString
=
None
def
__str__
(
self
):
size1
=
len
(
self
.
SenderCertificate
)
if
self
.
SenderCertificate
is
not
None
else
None
len
(
self
.
SenderCertificate
)
if
self
.
SenderCertificate
is
not
None
else
None
size2
=
len
(
self
.
ReceiverCertificateThumbPrint
)
if
self
.
ReceiverCertificateThumbPrint
is
not
None
else
None
return
f'
{
self
.
__class__
.
__name__
}
(SecurityPolicy:
{
self
.
SecurityPolicyURI
}
,'
\
f' certificatesize:
{
size2
}
, receiverCertificatesize:
{
size2
}
)'
...
...
asyncua/ua/uatypes.py
View file @
10a2272a
...
...
@@ -10,7 +10,7 @@ from enum import Enum, IntEnum
import
uuid
import
re
import
itertools
from
datetime
import
datetime
,
timedelta
,
MAXYEAR
,
timezone
from
datetime
import
datetime
,
timedelta
,
timezone
from
dataclasses
import
dataclass
,
field
# hack to support python < 3.8
...
...
examples/client-custom-structures-and-enums.py
View file @
10a2272a
import
asyncio
import
logging
from
asyncua
import
Client
,
Node
,
ua
from
asyncua
import
Client
,
ua
from
asyncua.common.structures104
import
load_custom_struct
...
...
examples/client-subscription.py
View file @
10a2272a
import
sys
sys
.
path
.
insert
(
0
,
".."
)
import
os
# os.environ['PYOPCUA_NO_TYPO_CHECK'] = 'True'
import
asyncio
...
...
examples/client-with-encryption.py
View file @
10a2272a
...
...
@@ -2,7 +2,7 @@ import asyncio
import
logging
import
sys
sys
.
path
.
insert
(
0
,
".."
)
from
asyncua
import
Client
,
Node
,
ua
from
asyncua
import
Client
from
asyncua.crypto.security_policies
import
SecurityPolicyBasic256Sha256
logging
.
basicConfig
(
level
=
logging
.
INFO
)
...
...
examples/client_play_with_type_definition.py
View file @
10a2272a
...
...
@@ -5,8 +5,8 @@ import logging
from
IPython
import
embed
from
asyncua
import
Client
,
ua
from
asyncua.common.structures104
import
make_structure_code
,
load_enums
from
asyncua
import
Client
from
asyncua.common.structures104
import
load_enums
async
def
main
():
...
...
examples/client_read-custom_structures.py
View file @
10a2272a
import
sys
sys
.
path
.
insert
(
0
,
".."
)
import
time
import
logging
import
asyncio
from
IPython
import
embed
from
asyncua
import
Client
from
asyncua
import
ua
async
def
main
():
...
...
examples/client_to_demo-this.com.py
View file @
10a2272a
...
...
@@ -6,7 +6,6 @@ import asyncio
from
IPython
import
embed
from
asyncua
import
Client
from
asyncua
import
ua
...
...
examples/client_to_kepware.py
View file @
10a2272a
...
...
@@ -3,7 +3,7 @@ import asyncio
sys
.
path
.
insert
(
0
,
".."
)
import
logging
from
asyncua
import
Client
,
ua
from
asyncua
import
Client
class
SubHandler
(
object
):
...
...
examples/client_to_prosys.py
View file @
10a2272a
import
asyncio
import
logging
from
asyncua
import
Client
,
ua
from
asyncua
import
Client
class
SubHandler
(
object
):
...
...
examples/client_to_uanet_alarm_conditions.py
View file @
10a2272a
...
...
@@ -23,7 +23,7 @@ class SubHandler:
conditionId
=
event
.
NodeId
.
to_string
()
conditionKeys
=
self
.
currentConditions
.
keys
()
# A alarm/condition appears with Retain=True and disappears with Retain=False
if
event
.
Retain
and
not
conditionId
in
conditionKeys
:
if
event
.
Retain
and
conditionId
not
in
conditionKeys
:
self
.
currentConditions
[
conditionId
]
=
event
if
not
event
.
Retain
and
conditionId
in
conditionKeys
:
del
self
.
currentConditions
[
conditionId
]
...
...
examples/finitestatemachine-example.py
View file @
10a2272a
import
asyncio
import
logging
from
asyncua
import
Server
,
ua
,
Node
from
asyncua
import
Server
,
ua
from
asyncua.common.statemachine
import
FiniteStateMachine
,
State
,
Transition
logging
.
basicConfig
(
level
=
logging
.
INFO
)
...
...
examples/perf-client.py
View file @
10a2272a
import
time
import
uvloop
import
asyncio
import
sys
import
logging
import
cProfile
sys
.
path
.
insert
(
0
,
".."
)
from
asyncua
import
Client
,
ua
...
...
examples/server-callback.py
View file @
10a2272a
...
...
@@ -13,7 +13,7 @@ except ImportError:
shell
.
interact
()
from
asyncua
import
ua
,
Server
from
asyncua
import
Server
from
asyncua.common.callback
import
CallbackType
...
...
examples/server-custom-object.py
View file @
10a2272a
...
...
@@ -8,7 +8,6 @@ import sys
sys
.
path
.
insert
(
0
,
".."
)
import
asyncio
import
asyncua
from
asyncua
import
ua
,
Server
...
...
examples/server-enums-before-1.04.py
View file @
10a2272a
...
...
@@ -8,7 +8,6 @@ sys.path.insert(0, "..")
import
time
import
asyncio
from
IPython
import
embed
from
asyncua
import
ua
,
Server
...
...
examples/server-events.py
View file @
10a2272a
import
asyncio
import
logging
from
asyncua
import
ua
from
asyncua.server
import
Server
,
EventGenerator
from
asyncua.server
import
Server
logging
.
basicConfig
(
level
=
logging
.
INFO
)
_logger
=
logging
.
getLogger
(
'asyncua'
)
...
...
examples/server-instantiate-object.py
View file @
10a2272a
...
...
@@ -2,7 +2,7 @@ import sys
sys
.
path
.
insert
(
0
,
".."
)
import
asyncio
from
asyncua
import
ua
,
Server
from
asyncua
import
Server
from
asyncua.common.instantiate_util
import
instantiate
...
...
examples/server-limits.py
View file @
10a2272a
import
asyncio
import
logging
from
asyncua
import
Server
,
ua
from
asyncua
import
Server
from
asyncua.common.methods
import
uamethod
...
...
examples/server-robotics.py
View file @
10a2272a
...
...
@@ -2,9 +2,8 @@ import asyncio
import
logging
import
sys
sys
.
path
.
insert
(
0
,
".."
)
from
IPython
import
embed
from
asyncua
import
ua
,
uamethod
,
Server
from
asyncua
import
Server
async
def
main
():
...
...
examples/server-virtual-network.py
View file @
10a2272a
...
...
@@ -3,7 +3,7 @@ import asyncio
import
sys
sys
.
path
.
insert
(
0
,
".."
)
from
asyncua
import
ua
,
Server
from
asyncua
import
Server
from
asyncua.common.methods
import
uamethod
...
...
examples/server-with-encryption.py
View file @
10a2272a
...
...
@@ -6,7 +6,6 @@ sys.path.insert(0, "..")
from
asyncua
import
Server
from
asyncua
import
ua
from
asyncua.crypto.permission_rules
import
SimpleRoleRuleset
from
asyncua.server.users
import
UserRole
from
asyncua.server.user_managers
import
CertificateUserManager
logging
.
basicConfig
(
level
=
logging
.
INFO
)
...
...
examples/server-xmlexporter.py
View file @
10a2272a
...
...
@@ -2,7 +2,7 @@ import sys
sys
.
path
.
insert
(
0
,
".."
)
import
asyncio
from
asyncua
import
ua
,
Server
from
asyncua
import
Server
from
asyncua.common.instantiate_util
import
instantiate
from
asyncua.common.xmlexporter
import
XmlExporter
...
...
examples/statemachine-example.py
View file @
10a2272a
import
asyncio
import
logging
from
asyncua
import
Server
,
ua
,
Node
from
asyncua
import
Server
,
ua
from
asyncua.common.statemachine
import
StateMachine
,
State
,
Transition
logging
.
basicConfig
(
level
=
logging
.
INFO
)
...
...
tests/conftest.py
View file @
10a2272a
...
...
@@ -91,7 +91,7 @@ class ServerProcess(Process):
async
def
wait_for_start
(
self
):
with
ThreadPoolExecutor
()
as
pool
:
result
=
await
asyncio
.
get_running_loop
().
run_in_executor
(
pool
,
self
.
wait_for_start_sync
)
await
asyncio
.
get_running_loop
().
run_in_executor
(
pool
,
self
.
wait_for_start_sync
)
def
wait_for_start_sync
(
self
):
with
self
.
cond
:
...
...
tests/test_common.py
View file @
10a2272a
...
...
@@ -150,7 +150,7 @@ async def test_delete_nodes(opc):
async
def
test_node_bytestring
(
opc
):
obj
=
opc
.
opc
.
nodes
.
objects
var
=
await
obj
.
add_variable
(
ua
.
ByteStringNodeId
(
b'VarByteString'
,
2
),
ua
.
QualifiedName
(
"toto"
,
2
),
ua
.
UInt16
(
9
))
node
=
opc
.
opc
.
get_node
(
f
"ns=2;b=VarByteString"
)
node
=
opc
.
opc
.
get_node
(
"ns=2;b=VarByteString"
)
assert
node
==
var
node
=
opc
.
opc
.
get_node
(
f"ns=2;b=0x
{
b'VarByteString'
.
hex
()
}
"
)
assert
node
==
var
...
...
tests/test_connections.py
View file @
10a2272a
# coding: utf-8
import
asyncio
import
pytest
import
asyncio
import
struct
from
asyncua
import
Client
,
Server
,
ua
...
...
tests/test_crypto_connect.py
View file @
10a2272a
...
...
@@ -4,7 +4,7 @@ import asyncio
from
asyncio
import
TimeoutError
from
asyncua.crypto.uacrypto
import
CertProperties
,
check_certificate
from
asyncua.crypto.uacrypto
import
CertProperties
from
asyncua
import
Client
from
asyncua
import
Server
...
...
tests/test_server.py
View file @
10a2272a
...
...
@@ -211,7 +211,7 @@ async def test_get_event_from_type_node_Inhereted_AuditEvent(server):
assert
ev
.
EventType
==
ua
.
NodeId
(
ua
.
ObjectIds
.
AuditEventType
)
assert
ev
.
Severity
==
1
assert
ev
.
ActionTimeStamp
is
None
assert
ev
.
Status
==
False
assert
ev
.
Status
is
False
assert
ev
.
ServerId
is
None
assert
ev
.
ClientAuditEntryId
is
None
assert
ev
.
ClientUserId
is
None
...
...
@@ -318,7 +318,7 @@ async def test_eventgenerator_inherited_event(server):
assert
ua
.
NodeId
(
ua
.
ObjectIds
.
AuditEventType
)
==
ev
.
EventType
assert
1
==
ev
.
Severity
assert
ev
.
ActionTimeStamp
is
None
assert
False
==
ev
.
Status
assert
False
is
ev
.
Status
assert
ev
.
ServerId
is
None
assert
ev
.
ClientAuditEntryId
is
None
assert
ev
.
ClientUserId
is
None
...
...
tests/test_subscriptions.py
View file @
10a2272a
...
...
@@ -5,7 +5,6 @@ from copy import copy
from
asyncio
import
Future
,
sleep
,
wait_for
,
TimeoutError
from
datetime
import
datetime
,
timedelta
from
asyncua.common.subscription
import
Subscription
from
typing
import
List
try
:
from
unittest.mock
import
AsyncMock
except
ImportError
:
...
...
tests/test_unit.py
View file @
10a2272a
...
...
@@ -625,7 +625,7 @@ def test_datavalue():
def
test_variant
():
dv
=
ua
.
Variant
(
True
,
ua
.
VariantType
.
Boolean
)
assert
dv
.
Value
==
True
assert
dv
.
Value
is
True
assert
type
(
dv
.
Value
)
==
bool
now
=
datetime
.
utcnow
()
v
=
ua
.
Variant
(
now
)
...
...
@@ -849,7 +849,7 @@ def test_struct_104():
a
:
ua
.
Int32
=
1
b
:
Optional
[
ua
.
Int32
]
=
None
c
:
Optional
[
ua
.
String
]
=
None
l
:
List
[
ua
.
String
]
=
None
l
:
List
[
ua
.
String
]
=
None
# noqa: E741
m
=
MyStruct
()
data
=
struct_to_binary
(
m
)
...
...
tests/util_enum_struct.py
View file @
10a2272a
...
...
@@ -4,6 +4,7 @@ from pathlib import Path
from
asyncua
import
Server
,
ua
from
asyncua.ua
import
uatypes
import
asyncua.ua
TEST_DIR
=
Path
(
__file__
).
parent
...
...
@@ -14,12 +15,9 @@ class ExampleEnum(IntEnum):
EnumVal3
=
2
import
asyncua.ua
setattr
(
asyncua
.
ua
,
'ExampleEnum'
,
ExampleEnum
)
@
dataclass
class
ExampleStruct
:
IntVal1
:
uatypes
.
Int16
=
0
...
...
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