From 2f8f1e0abd3d858f39e9fe09ff425f14500f8a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20H=C3=A9zser?= Date: Fri, 9 Apr 2021 18:59:33 +0200 Subject: [PATCH 1/2] added cffi install requirement --- MachineDemoServer/Python/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MachineDemoServer/Python/README.md b/MachineDemoServer/Python/README.md index a0d2bb7..2b59de2 100644 --- a/MachineDemoServer/Python/README.md +++ b/MachineDemoServer/Python/README.md @@ -23,6 +23,7 @@ Alarms and Conditions can only be subscribed on the "Messages" node. The Conditi ### Requirements - Python >= Python 3.7 - Python opcua-asyncio library >= 0.9.14 +- Python cffi >= 1.14.5 ### Installation and Execution With Python installed, the script file can be exuted with `python PythonMachineDemoServer.py`. As an alternative a fully self contained .exe can be created with PyInstaller. @@ -31,8 +32,10 @@ With Python installed, the script file can be exuted with `python PythonMachineD - [Download and install Python](https://www.python.org/downloads/) >= Python 3.7. On installation set checkbox for adding to system path. - Install opcua-asnycio library >= 0.9.14 with `pip3 install asyncua` or upgrade with `pip3 install --upgrade asyncua` -Behind a company proxy you may need to add the proxy server and trust servers. Search for proxy settings and look for the manual proxy server. + + Behind a company proxy you may need to add the proxy server and trust servers. Search for proxy settings and look for the manual proxy server. `pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org --proxy=http://username:password@proxyserver:port asyncua` +- Install cffi library with `pip3 install cffi` - Download all files and copy them to a folder. Easiest way is to download all files of the github repository. [Download zip](https://github.com/TRUMPF-IoT/OpcUaMachineTools/archive/main.zip). - Enter the folder containing PythonMachineDemoServer.py and execute the server with `python PythonMachineDemoServer.py` From cfbbd95f3264188116fd64c2fc7a6659c067097c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20H=C3=A9zser?= Date: Mon, 19 Apr 2021 16:59:44 +0200 Subject: [PATCH 2/2] Added devcontainer for easy development/execution --- .../Python/.devcontainer/Dockerfile | 22 ++++++++ .../Python/.devcontainer/devcontainer.json | 52 +++++++++++++++++++ .../Python/ReplayConfiguration.xml | 2 +- MachineDemoServer/Python/requirements.txt | 2 + 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 MachineDemoServer/Python/.devcontainer/Dockerfile create mode 100644 MachineDemoServer/Python/.devcontainer/devcontainer.json create mode 100644 MachineDemoServer/Python/requirements.txt diff --git a/MachineDemoServer/Python/.devcontainer/Dockerfile b/MachineDemoServer/Python/.devcontainer/Dockerfile new file mode 100644 index 0000000..0e998f0 --- /dev/null +++ b/MachineDemoServer/Python/.devcontainer/Dockerfile @@ -0,0 +1,22 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/python-3/.devcontainer/base.Dockerfile + +# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6 +ARG VARIANT="3" +FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT} + +# [Option] Install Node.js +ARG INSTALL_NODE="true" +ARG NODE_VERSION="lts/*" +RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi + +# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image. +# COPY requirements.txt /tmp/pip-tmp/ +# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ +# && rm -rf /tmp/pip-tmp + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment this line to install global node packages. +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file diff --git a/MachineDemoServer/Python/.devcontainer/devcontainer.json b/MachineDemoServer/Python/.devcontainer/devcontainer.json new file mode 100644 index 0000000..5294540 --- /dev/null +++ b/MachineDemoServer/Python/.devcontainer/devcontainer.json @@ -0,0 +1,52 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.166.1/containers/python-3 +{ + "name": "Python 3", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + // Update 'VARIANT' to pick a Python version: 3, 3.6, 3.7, 3.8, 3.9 + "VARIANT": "3.7", + // Options + "INSTALL_NODE": "false", + "NODE_VERSION": "lts/*" + } + }, + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/local/bin/python", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.formatting.provider": "autopep8", + "python.formatting.autopep8Args": [ + "--max-line-length=200" + ], + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-python.python" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [ 5000 ], + "appPort": 5000, + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "pip3 install --user -r requirements.txt", + + // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/MachineDemoServer/Python/ReplayConfiguration.xml b/MachineDemoServer/Python/ReplayConfiguration.xml index 1511f5b..63fdbe0 100644 --- a/MachineDemoServer/Python/ReplayConfiguration.xml +++ b/MachineDemoServer/Python/ReplayConfiguration.xml @@ -1,5 +1,5 @@ - + diff --git a/MachineDemoServer/Python/requirements.txt b/MachineDemoServer/Python/requirements.txt new file mode 100644 index 0000000..b9f761c --- /dev/null +++ b/MachineDemoServer/Python/requirements.txt @@ -0,0 +1,2 @@ +asyncua +cffi \ No newline at end of file