beremiz

py_ext: fix CSV Writer

18 months ago, Edouard Tisserant
d2f5eb3c7d6e
py_ext: fix CSV Writer

fix POU logic :
- SAVE is a BOOL
- invocation of py_eval on rising edge of SAVE
- remove save python argument

fix python:
- use no encoding for file open (python2)
- re-use detected dialect if any
- use no "rt+" and truncate since no need to re-sniff dialect for output file
- return "OK" instead of "#SUCCESS", preventing POU logic to ACK result
- support creating new line if writing just after last line
- support appending data on short rows

fix example:
- use a HMI:Button to trigger CSV write instead of HMI:Input +1
- reload CSVs on on each new CSV opened in file browser
- add display of CSV write output
name: CI Automated testing
on:
push:
branches: [ python3 ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
path: beremiz
- uses: actions/checkout@v3
with:
repository: beremiz/matiec
ref: bc38335298d4faa949ddbefedaa55cccfcf94eda
path: matiec
- uses: actions/checkout@v3
with:
repository: open62541/open62541
# v1.3.7
ref: b8ac9e77f703e6ba5c012b886a8821037503daa6
path: open62541
submodules: recursive
- uses: actions/checkout@v3
with:
repository: beremiz/Modbus
ref: 4d7d67a8e911d744165709c20a254b5cb924ec71
path: Modbus
- uses: actions/checkout@v3
with:
repository: beremiz/erpc
# v1.13.0 + no CRC on TCP
ref: d8fff72b15274b5f2a8f7895d9bc5c91eef584ec
path: erpc
- name: Restore cached docker image
id: cache-docker-restore
uses: actions/cache/restore@v3
env:
cache-name: cache-docker
with:
path: /tmp/latest.tar
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('beremiz/tests/tools/Docker', 'beremiz/requirements.txt') }}
- if: ${{ steps.cache-docker-restore.outputs.cache-hit == false }}
name: Create docker image
run: |
cd beremiz/tests/tools/Docker
./build_docker_image.sh
docker image save --output="/tmp/latest.tar" beremiz_sikuli
- if: ${{ steps.cache-docker-restore.outputs.cache-hit == false }}
name: Save docker image in cache
id: cache-docker-save
uses: actions/cache/save@v3
with:
path: /tmp/latest.tar
key: ${{ steps.cache-docker-restore.outputs.cache-primary-key }}
- if: ${{ steps.cache-docker-restore.outputs.cache-hit != false }}
name: Re-use docker image
run: |
docker image load --input="/tmp/latest.tar"
- name: Create docker container
run: |
cd beremiz/tests/tools/Docker
./create_docker_container.sh ${{ github.workspace }}/test
- name: Run tests in docker
run: |
cd beremiz/tests/tools/Docker
./do_test_in_docker.sh
- name: Upload test resuts artifact
uses: actions/upload-artifact@v3
if: failure()
with:
name: test_results
path: ${{ github.workspace }}/test
retention-days: 5