Commit 36ee457a authored by Alexander Schrode's avatar Alexander Schrode Committed by oroulet

Squashed commit of the following:

commit 02525a63
Author: Bamberator <serg_main@inbox.ru>
Date:   Sat Nov 27 16:06:12 2021 +0500

    add method read_data_value

commit 933f4cb0
Author: Jordi Mariné Fort <jmarine@tinet.org>
Date:   Sun Nov 21 20:43:43 2021 +0100

    Fixes data change notifications

commit 6a6b13e6
Author: Julien Prigent <prigentj@fb.com>
Date:   Fri Nov 19 12:34:46 2021 +0100

    [HaClient] Allow init from executor

    With py3.10, high level asyncio API can't specify the event_loop
    argument anymore.

    Consequently When using thread dedicated to run the event_.loop, we now need to
    instantiate object like asyncio.Lock within the thread. However, the
    event loop can't be running before creating these objects as
    `loop.run_for_ever()` must be the background running thread process.
    Therefore we can't have "get_running_loop()" calls in object
    constructors (like HaClient)
    when used with executors.

    Before
    ```
    In [15]: def get_t():
        ...:     loop = asyncio.new_event_loop()
        ...:     t = T()
        ...:     loop.run_for_ever()

    In [16]: class T:
        ...:     def __init__(self, loop):
        ...:         asyncio.set_event_loop(loop)
        ...:         asyncio.get_running_loop()
        ...:         self.l = asyncio.Lock()
        ...:         print("Lock created")
        ...:

    In [17]: t = Thread(target=get_t);t.start()

    Exception in thread Thread-9:
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    In [41]:     self.run()
      File "/usr/local//lib/python3.8/threading.py", line 870, in run
    In [41]:     self._target(*self._args, **self._kwargs)
      File "<ipython-input-32-c4a1ea4cfdac>", line 3, in get_t
      File "<ipython-input-39-ebeae10dd173>", line 4, in __init__
    RuntimeError: no running event loop
    ```
    After

    ```
    In [15]: def get_t():
        ...:     loop = asyncio.new_event_loop()
        ...:     t = T()
        ...:     loop.run_for_ever()

    In [16]: class T:
        ...:     def __init__(self, loop):
        ...:         asyncio.set_event_loop(loop)
        ...:         self.l = asyncio.Lock()
        ...:         print("Lock created")
        ...:

    In [17]: t = Thread(target=get_t);t.start()

    Lock created

    ```

commit 4041d26c
Author: Andreas <info@andreas-heine.net>
Date:   Mon Nov 15 12:58:20 2021 +0100

    Revert "fix in _create_custom_type"

    This reverts commit 49fefd4d.

commit 49fefd4d
Author: Andreas Heine <56362817+AndreasHeine@users.noreply.github.com>
Date:   Mon Nov 15 12:46:37 2021 +0100

    fix in _create_custom_type

    fix add properties/variables in _create_custom_type

commit 77796a37
Author: janfelixklein <47968254+janfelixklein@users.noreply.github.com>
Date:   Fri Nov 12 16:04:07 2021 +0100

    Changes to xmlimporter to load customn data types when needed (#719)

    * Update xmlimporter.py

    This allows to load information about newly created data types in the same import process

    * Update xmlparser.py

    with this we can set the value to newly created datatypes

    * Update ua_utils.py

    This is conform to the I40AAS nodeset enumerations, e.g. given enumeration as "AccessPermissionRule_0" specifying the type and the integer

    * Update xmlimporter.py

    small changes due to necessary async and await

    * Update xmlparser.py

    switched from try/catch to check

commit 9b717c81
Author: oroulet <olivier@r-dt.net>
Date:   Fri Nov 12 08:40:37 2021 +0100

    new release v0.9.92

commit 86e9cc15
Author: oroulet <olivier@r-dt.net>
Date:   Thu Nov 11 19:45:06 2021 +0100

    do not overwite args in VariableAttribute and Argument

commit 560eb91e
Author: Julien Prigent <prigentj@fb.com>
Date:   Thu Nov 11 08:18:15 2021 +0000

    [Safe Client disconnect]
    Follow-up of #711
    Make sure calling disconnect is safe when connection isn't established
    or half-established (i.e: protocol/transport exist but session is not
    ready).

    Test1
    Call to disconnect is safe when there's no existing connection
    ```
    > python -m IPython
    Python 3.10.0 (default, Oct 13 2021, 06:45:00) [Clang 13.0.0 (clang-1300.0.29.3)]

    In [1]: import sys; sys.path.insert(0, "~/Documents/github/opcua-asyncio"); import asyncua; c = asyncua.Client(url="opc.tcp://localhost:4840",timeout=10
       ...: );

    In [2]: await c.disconnect()
    close_session but connection wasn't established
    close_secure_channel was called but connection is closed

    In [3]:
    ```
    Test2

    Calling to disconnect is safe when there's no session established.
    To simulate this, I add delay to the server internal_session on session
    creation. I check that the client connects and disconnect from the
    server logs. Finally, the client doesn't raise any error.
    Ad delay to the internal server
    ```
    > python -m IPython
    Python 3.10.0 (default, Oct 13 2021, 06:45:00) [Clang 13.0.0 (clang-1300.0.29.3)]
    In [1]: import sys; sys.path.insert(0, "~/Documents/github/opcua-asyncio"); import asyncua; c = asyncua.Client(url="opc.tcp://localhost:4840",timeout=10
       ...: ); import threading; import asyncio;

    In [2]:

    In [2]: async def connect(c):
       ...:     await c.connect()
       ...:

    In [3]: async def disco(c):
       ...:     await c.disconnect()
       ...:

    In [4]: L = await asyncio.gather(connect(c), disco(c))
    close_session but connection wasn't established
    close_secure_channel was called but connection is closed

    In [5]: quit;
    ```

commit b5edbdeb
Author: Julien Prigent <prigentj@fb.com>
Date:   Wed Nov 10 10:50:23 2021 +0000

    [HaClient] Fix test race condition

    According to the logs of the recent test failure, there's a small window when we test the connection is established where we have a socket connected but don't have the session created yet, and this is throwing exception when trying to disconnect because the renew loop is not yet created.

    This is caused by the HaManager (in charge of connecting/reconnecting the clients) running in its own task, thus we're not in the usual await connect(); await disconnect() scenario.
    This can also arguably be fixed at the client level by checking if
    the renew loop exist on disconnect.

commit 68b50bbf
Author: oroulet <olivier@r-dt.net>
Date:   Thu Nov 11 19:23:25 2021 +0100

    try to not overwrite arguments in VariableAttributes

commit 1449ba53
Author: oroulet <olivier@r-dt.net>
Date:   Thu Nov 11 16:18:51 2021 +0100

    revert and fix Variant array

commit 100a711b
Author: Julien Prigent <prigentj@fb.com>
Date:   Tue Nov 9 12:36:25 2021 +0000

    [PyPi] Missing files

    The HaClient is missing from the PyPi package:

    ```
    [/tmp]> curl https://codeload.github.com/FreeOpcUa/opcua-asyncio/tar.gz/refs/tags/v0.9.91 -s -o v0.9.91.tar.gz
    [/tmp]> tar xvf v0.9.91.tar.gz > /dev/null 2>&1
    [/tmp]> cd opcua-asyncio-0.9.91/
    [/tmp/opcua-asyncio-0.9.91]> python setup.py install > /dev/null 2>&1
    [/tmp/opcua-asyncio-0.9.91]> find build/ -type f |grep -i ha
    build//lib/tests/test_ha_client.py
    build//lib/asyncua/ua/uaprotocol_hand.py
    ```

    The build rules only look for the packages via
    (`find_packages`) in setup.py, making the ha client sub-directory a
    package fixes it:
    ```
    [/tmp/opcua-asyncio-0.9.91]> rm -rf build/
    [/tmp/opcua-asyncio-0.9.91]> cat asyncua/client/ha/__init__.py
    """
    Pure Python OPC-UA library
    """

    from .ha_client import HaClient, HaMode, HaSecurityConfig, ConnectionStatesing
    [/tmp/opcua-asyncio-0.9.91]> python setup.py build > /dev/null 2>&1
    [/tmp/opcua-asyncio-0.9.91]> find build/ -type f |grep -i ha
    build//lib/tests/test_ha_client.py
    build//lib/asyncua/ua/uaprotocol_hand.py
    build//lib/asyncua/client/ha/__init__.py
    build//lib/asyncua/client/ha/common.py
    build//lib/asyncua/client/ha/ha_client.py
    build//lib/asyncua/client/ha/reconciliator.py
    build//lib/asyncua/client/ha/virtual_subscription.py
    ```

    Changing the HaClient test import path to ensure no regression.

commit ba8f7ec7
Author: oroulet <olivier@r-dt.net>
Date:   Fri Nov 5 18:39:57 2021 +0100

    ha_client fixes for python3.10

commit a73affdf
Author: oroulet <olivier@r-dt.net>
Date:   Fri Nov 5 17:49:24 2021 +0100

    iupdate CI python versions

commit 3d94d609
Author: oroulet <oroulet@users.noreply.github.com>
Date:   Fri Nov 5 19:41:03 2021 +0100

    Create codeql-analysis.yml

commit 78b71cc8
Author: Christopher Bremner <chrisjbremner@gmail.com>
Date:   Fri Nov 5 10:44:27 2021 -0700

    Fix test: don't shadow "res"

commit b0c2b7ad
Author: Christopher Bremner <chrisjbremner@gmail.com>
Date:   Fri Nov 5 10:23:26 2021 -0700

    Avoid false warning when deleting subscription

commit 98c20003
Author: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
Date:   Fri Nov 5 15:53:43 2021 +0100

    Remove unused imports

commit b57173cc
Author: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
Date:   Fri Nov 5 15:30:30 2021 +0100

    50% speedup in serialization of ua payloads with a timestamp

commit 5f99b3c7
Author: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
Date:   Fri Nov 5 11:54:08 2021 +0100

    3x faster message deserialization

    Avoid running introspection code every time a message is deserialized

    See https://github.com/FreeOpcUa/opcua-asyncio/pull/700

commit 97aba791
Author: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
Date:   Wed Nov 3 18:24:06 2021 +0100

    small perf improvement in variant_to_binary

commit 93d9ddfe
Author: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
Date:   Wed Nov 3 17:52:29 2021 +0100

    improve Variant serialization performance

commit 05acc76a
Author: Curious Crook <70259149+CuriousCrook@users.noreply.github.com>
Date:   Fri Nov 5 12:54:20 2021 +0100

    Reduction of network access (#705)

    * Reduction of network access

    Cache the nodes of potentially multiple-used FileType methods.

    * indentation error corrected

commit 6b0c12d8
Author: oroulet <olivier@r-dt.net>
Date:   Wed Nov 3 12:44:33 2021 +0100

    new release v0.9.91

commit f57477ae
Author: Curious Crook <70259149+CuriousCrook@users.noreply.github.com>
Date:   Wed Nov 3 12:42:59 2021 +0100

    Add client low-level file system functionality (#696)

    * Add low-level file system functionality

    * Added examples for the use of ua_file_transfer.py

    In the following you will find examples for the use of the
    classes UaFile and UaDirectory and how to handle typical uaerrors.
    see: ./asyncua/client/ua_file_transfer.py.

    The OPC UA File Transfer specification can be found here:
    https://reference.opcfoundation.org/Core/docs/Part5/C.1/

    * pylint optimized - ua_file_transfer.py

    pylint optimization of file ua_file_transfer.py.
    => Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

    * pylint optimized - client_ua_file_transfer.py

    pylint optimization of client_ua_file_transfer.py.
    => Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
Co-authored-by: default avatarCurious Crook <privat@nowhere.org>

commit 0f4f68cd
Author: Markus Elfring <elfring@users.sourceforge.net>
Date:   Sun Oct 31 21:10:07 2021 +0100

    Issue #702: Convert three statements to the usage of augmented assignments

    Augmented assignment statements became available with Python 2.
    https://docs.python.org/3/whatsnew/2.0.html#augmented-assignment

    Thus improve three source code places accordingly.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>

commit 89c48a1f
Author: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
Date:   Thu Oct 28 16:15:51 2021 +0200

    Prevent the test suite from creating files in the current working directory

    The test suite used to create files in the CWD, which then showed up as untracked files in git, and would cause the tests to fail when ran successively with different users.

    This commit makes successive test runs independant from each other

commit 3932c3f4
Author: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
Date:   Tue Oct 26 15:49:54 2021 +0200

    3x performance improvement for serialization (#700)

    * 3x performance improvement for serialization

    Instead of re-inspecting the type metadata everytime an object is serialized,
    create a single serialization function for each type and just call it when an instance is serialized

    * pre-compute uatype array serializers

    * Make VariantTypeCustom instances valid cache keys

    VariantTypeCustom instances can be used as cache keys for serialization functions

commit 8d4b9bae
Author: Ondřej Novák <42471077+ondrejnovakcvut@users.noreply.github.com>
Date:   Tue Oct 26 13:21:35 2021 +0200

    Enable the server to listen to an arbitrary IP (#687)

    * Enable the server to listen to an arbitrary IP

    * Add missing doc
Co-authored-by: default avataroroulet <oroulet@users.noreply.github.com>

commit f5301a41
Author: oroulet <olivier@r-dt.net>
Date:   Mon Oct 18 15:42:31 2021 +0200

    clean up some if clauses in Variant

commit 4d5c5b9a
Author: oroulet <olivier@r-dt.net>
Date:   Sun Oct 17 20:41:04 2021 +0200

    remove is_array argument from Variant, it is redundant, one can specify Dimensions

commit 35bb6207
Author: oroulet <olivier@r-dt.net>
Date:   Thu Oct 21 12:25:27 2021 +0200

    add some missing typing and correct timeout type!

commit 8d8edbd6
Author: oroulet <olivier@r-dt.net>
Date:   Mon Oct 25 15:07:25 2021 +0200

    correct vtype_to_argument to suport Node and NodeId and enums

commit a69566c5
Author: Curious Crook <70259149+CuriousCrook@users.noreply.github.com>
Date:   Fri Oct 8 08:02:16 2021 +0200

    Add functionality to connect by user certificates

    With this change you can authenticate via user certificate over sync api.
    The application-uri is required, because some servers will reject the connection if the application-uri of the application does not match the one from the client application certificate.

commit 83b3fc88
Author: Curious Crook <70259149+CuriousCrook@users.noreply.github.com>
Date:   Fri Oct 8 07:49:26 2021 +0200

    Add common.methods.call_method to sync api

commit cf4943c6
Author: Alexander Schrode <Midix01@googlemail.com>
Date:   Thu Oct 7 21:00:18 2021 +0200

    Loading of OptionSets

    Allow using OptionSets from Addresspace und dynamic creation of OptionSets

commit 05ba8ffa
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 11:05:42 2021 +0200

    Fix spelling of “instantiated”

commit bced9068
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 11:01:04 2021 +0200

    Fix incorrect docstrings in node class

commit 34e2e582
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:57:01 2021 +0200

    Fix spelling of “optionally”

commit 5e1c5a7e
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:56:15 2021 +0200

    Fix incorrect docstring in node class

commit 620fe4bb
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:54:37 2021 +0200

    Fix spelling of “Parameters”

commit d4879b80
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:38:55 2021 +0200

    Fix spelling of “modify”

commit 7e582c9c
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:37:21 2021 +0200

    Fix spelling of “session”

commit 40ff37d0
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:36:41 2021 +0200

    Fix spelling of “symmetry”

commit 3e34ba41
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:35:40 2021 +0200

    Fix spelling of “useful”

commit 86dec4e6
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:34:32 2021 +0200

    Fix spelling of “Registering”

commit 39d0e047
Author: René Schwaiger <sanssecours@me.com>
Date:   Wed Sep 22 10:31:03 2021 +0200

    Fix Spelling of “attribute”

commit a98ffa3e
Author: oroulet <olivier@r-dt.net>
Date:   Wed Oct 6 21:45:35 2021 +0200

    one more bytestring test

commit 0c6d1123
Author: oroulet <olivier@r-dt.net>
Date:   Wed Oct 6 21:15:38 2021 +0200

    correctly import/export BytestringNodeId

commit dd351f57
Author: Marko Kohtala <marko.kohtala@gmail.com>
Date:   Tue Oct 5 13:24:50 2021 +0300

    Add missing await in uals -l -d

    Running uals recursively with -l option gives RuntimeWarning:

    ```
    $ uals -d 3 -l
    Browsing node i=84 at opc.tcp://localhost:4840

    DisplayName                    NodeId                    BrowseName                DataType   Timestamp                      Value

    Traceback (most recent call last):
      File ".../opcua-asyncio/tools/uals", line 11, in <module>
        uals()
      File ".../opcua-asyncio/asyncua/tools.py", line 342, in uals
        asyncio.run(_uals())
      File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
        return loop.run_until_complete(main)
      File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
        return future.result()
      File ".../opcua-asyncio/asyncua/tools.py", line 368, in _uals
        await _lsprint_long(node, args.depth - 1)
      File ".../opcua-asyncio/asyncua/tools.py", line 442, in _lsprint_long
        name, bname, nclass, mask, umask, dtype, val = [attr.Value.Value for attr in attrs]
    TypeError: 'coroutine' object is not iterable
    sys:1: RuntimeWarning: coroutine 'Node.read_attributes' was never awaited
    ```

commit b19881b9
Author: Alexander Schrode <Midix01@googlemail.com>
Date:   Sun Oct 3 16:52:12 2021 +0200

    Support OptionSets

    Support OptionSets from Part5 7.17 like UadpNetworkMessageContentMask. In nodesets they are UAEnumerations with attribut "IsOptionSet" = True

commit cd9efa7b
Author: Alexander Schrode <Midix01@googlemail.com>
Date:   Sun Sep 26 21:39:28 2021 +0200

    Fix default GUID

    Fixed generation for default values for GUID. Now an empty GUID is generated.

commit bd0b51b8
Author: Julien Prigent <julienprigent@wanadoo.fr>
Date:   Wed Sep 22 10:10:38 2021 -0700

    [Sec_Policy] Handle server certificate renewal gracefully

    When a client reconnects, it can require to clear its security_policy
    settings to deal with situations where the peer_certificate has
    changed for example (regular server cert renewal).

    This PR introduces the `reset_security_policy()` client method to handle
    this use-case, and adds it to the HaClient reconnection mechanism.

    Note: We could arguably invoke this method from `set_security()` as they
    often will be called together, but according to [OPC-UA Part4 5.4.4](https://reference.opcfoundation.org/v104/Core/docs/Part4/5.4.4/),
    the GetEndpoints service may require TLS and so enforcing an empty policy would break this use-case.

commit 49b611bd
Author: Curious Crook <70259149+CuriousCrook@users.noreply.github.com>
Date:   Mon Sep 27 10:27:10 2021 +0200

    Fix crash if server does not provide DiscoveryUrls

    The OPC UA specification does not forbid that a server does not offer DiscoveryUrls. This can lead to a crash when calling the function application_to_strings().

    Check DiscoveryUrls for None or empty before iterating to avoid the crash described in #1127.
parent 208a84fd
......@@ -466,6 +466,7 @@ class {name}({enum_type}):
name = clean_name(sfield.Name)
value = sfield.Value if not option_set else (1 << sfield.Value)
code += f" {name} = {value}\n"
logger.error(f"{name} - {sfield} {option_set} {code}")
return code
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment