Skip to content

Commit b6f5eb8

Browse files
committed
Create dev branch
1 parent 7c32458 commit b6f5eb8

File tree

13 files changed

+411
-152
lines changed

13 files changed

+411
-152
lines changed

.github/workflows/build.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Manual triggered GitHub action to build a self-contained binary of the Requests Python driver and attach it to a release draft including a hash file
2+
---
3+
name: "Build & Draft Release"
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- dev
10+
11+
env:
12+
INTG_NAME: requests
13+
HASH_FILENAME: intg-requests.hash
14+
# Python version to use in the builder image. See https://hub.docker.com/r/unfoldedcircle/r2-pyinstaller for possible versions.
15+
PYTHON_VER: 3.11.6-0.2.0
16+
17+
jobs:
18+
build:
19+
name: Build Release
20+
runs-on: ubuntu-latest
21+
#Save version to env output variable to be able to use it in the following release job as a tag
22+
outputs:
23+
version: ${{ steps.get-version.outputs.VERSION }}
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
with:
28+
# History of 200 should be more than enough to calculate commit count since last release tag
29+
fetch-depth: 200
30+
# Only for testing. Delete when merging with main branch
31+
ref: dev
32+
33+
- name: Get version
34+
#Needed for env output variable
35+
id: get-version
36+
run: |
37+
echo "VERSION=$(jq .version -r driver.json)" >> $GITHUB_ENV
38+
# Save to Github output to later use it in Create Release job
39+
echo "VERSION=$(jq .version -r driver.json)" >> $GITHUB_OUTPUT
40+
41+
- name: Build
42+
run: |
43+
sudo apt-get update && sudo apt-get install -y qemu binfmt-support qemu-user-static
44+
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
45+
echo "Starting pyinstaller build"
46+
docker run --rm --name builder \
47+
--platform=aarch64 \
48+
--user=$(id -u):$(id -g) \
49+
-v ${GITHUB_WORKSPACE}:/workspace \
50+
docker.io/unfoldedcircle/r2-pyinstaller:${PYTHON_VER} \
51+
bash -c \
52+
"cd /workspace && \
53+
python -m pip install -r requirements.txt && \
54+
pyinstaller --clean --onefile --name intg-${INTG_NAME} --collect-all zeroconf intg-${INTG_NAME}/driver.py"
55+
56+
- name: Add version
57+
run: |
58+
mkdir -p artifacts
59+
cd artifacts
60+
echo ${{ env.VERSION }} > version.txt
61+
62+
- name: Prepare artifacts
63+
shell: bash
64+
run: |
65+
cp dist/intg-${INTG_NAME} artifacts/
66+
cp driver.json artifacts/
67+
echo "ARTIFACT_NAME=uc-intg-${{ env.INTG_NAME }}-${{ env.VERSION }}-aarch64" >> $GITHUB_ENV
68+
69+
- name: Create upload artifact archive
70+
shell: bash
71+
run: |
72+
tar czvf ${{ env.ARTIFACT_NAME }}.tar.gz -C ${GITHUB_WORKSPACE}/artifacts .
73+
ls -lah
74+
75+
- uses: actions/upload-artifact@v4
76+
id: upload_artifact
77+
with:
78+
name: ${{ env.ARTIFACT_NAME }}
79+
path: ${{ env.ARTIFACT_NAME }}.tar.gz
80+
if-no-files-found: error
81+
retention-days: 3
82+
83+
release:
84+
name: Create Release
85+
runs-on: ubuntu-latest
86+
needs: [build]
87+
permissions:
88+
contents: write
89+
90+
steps:
91+
- name: Download build artifacts
92+
uses: actions/download-artifact@v4
93+
94+
- name: Extract build archives from downloaded files
95+
run: |
96+
ls -R
97+
# extract tar.gz build archives from downloaded artifacts
98+
# (wrapped in tar from actions/upload-artifact, then extracted into a directory by actions/download-artifact)
99+
for D in *
100+
do if [ -d "${D}" ]; then
101+
mv $D/* ./
102+
fi
103+
done;
104+
105+
- name: Create hash file
106+
run: |
107+
for filename in *.tar.gz; do echo "sha256 `sha256sum $filename`" >> ${{ env.HASH_FILENAME }}; done;
108+
109+
- name: Create release draft
110+
uses: ncipollo/release-action@v1
111+
with:
112+
artifacts: "*.tar.gz,${{ env.HASH_FILENAME }}"
113+
draft: true
114+
generateReleaseNotes: true
115+
artifactErrorsFailBuild: true
116+
tag: v${{needs.build.outputs.version}}

.pylintrc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[FORMAT]
2+
3+
# Maximum number of characters on a single line.
4+
max-line-length=175
5+
6+
[MESSAGES CONTROL]
7+
8+
# Disable the message, report, category or checker with the given id(s). You
9+
# can either give multiple identifiers separated by comma (,) or put this
10+
# option multiple times (only on the command line, not in the configuration
11+
# file where it should appear only once).You can also use "--disable=all" to
12+
# disable everything first and then re-enable specific checks. For example, if
13+
# you want to run only the similarities checker, you can use "--disable=all
14+
# --enable=similarities". If you want to run only the classes checker, but have
15+
# no Warning level messages displayed, use"--disable=all --enable=classes
16+
# --disable=W"
17+
18+
disable=
19+
global-statement,
20+
too-many-instance-attributes,
21+
too-many-arguments,
22+
too-many-public-methods,
23+
fixme # temporary
24+
25+
[STRING]
26+
27+
# This flag controls whether inconsistent-quotes generates a warning when the
28+
# character used as a quote delimiter is used inconsistently within a module.
29+
check-quote-consistency=yes

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
*Changes in the next release*
11+
12+
### Breaking changes
13+
- The configuration json file is now created in the root of the repository. Existing users have to move the config.json file from the intg-requests directory
14+
- The working directory when starting driver.py should now be the root of the repository. The path in docker-entry.sh has been adjusted.
15+
- In preparation to the upcoming custom integration upload feature setup.json has been renamed to driver.json and moved to the root of the repository to adapt to the official UC integrations
16+
17+
### Added
18+
- The wake-on-lan entity now supports an ipv4/v6 address or a hostname (ipv4 only) as a parameter
19+
- Discover the mac address from an ip address or a hostname may not work on all systems. Please refer to the [getmac supported platforms](https://github.com/GhostofGoes/getmac?tab=readme-ov-file#platforms-currently-supported). Docker containers need to be run in the host network (`--net=host`)
20+
- Add build.yml Github action to automatically build a self-contained binary of the integration and create a release draft with the current driver version as a tag/name
21+
22+
### Changed
23+
- Corrected the semantic version scheme in driver.json (x.x to x.x.x)
24+
25+
26+
1027
## [0.2-beta] - 2024-06-26
1128

1229
### Breaking changes
@@ -16,11 +33,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1633

1734
- Added a more granular http status code response handling
1835
- Added optional parameter to send form data in the request body as key/value pairs (see README)
19-
- Added optional custom global entity-independent timeout and ssl verify option in the integration setup. For self signed ssl certificates to work the ssl verify option needs to be deactivated.
36+
- Added optional custom global entity-independent timeout and ssl verify options in the integration setup. For self signed ssl certificates to work the ssl verify option needs to be deactivated.
2037

2138
### Changed
2239
- Only return an error response to the remote if the http response code is in the 400 or 500 range. Otherwise display the status code in the integration log if it's not 200/Ok
2340

41+
42+
2443
## [0.1-beta] - 2024-04-27
2544

2645
### Added

README.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@
88

99
Integration for Unfolded Circle [Remote Two](https://www.unfoldedcircle.com/remote-two) and [Remote 3](https://www.unfoldedcircle.com) running [Unfolded OS](https://www.unfoldedcircle.com/unfolded-os) to send network requests to a specified url or mac address.
1010

11-
Using [uc-integration-api](https://github.com/aitatoi/integration-python-library), [requests](https://github.com/psf/requests) and [pywakeonlan](https://github.com/remcohaszing/pywakeonlan).
11+
Using [uc-integration-api](https://github.com/aitatoi/integration-python-library), [requests](https://github.com/psf/requests), [pywakeonlan](https://github.com/remcohaszing/pywakeonlan) and [getmac](https://github.com/GhostofGoes/getmac).
1212

1313

1414
### Supported features
1515

1616
- Send http(s) get, post, patch & put requests to a specified url
17-
- Set a custom timeout and deactivate ssl certificate verification
18-
- Send Wake on LAN magic packets to a specified mac address
17+
- Define a global custom timeout and deactivate ssl certificate verification during the integration setup
18+
- Send Wake on LAN magic packets to a specified mac address, ip (v4/v6) or hostname (ipv4 only)
19+
- Discover the mac address from an ip address or a hostname may not work on all systems. Please refer to the [getmac supported platforms](https://github.com/GhostofGoes/getmac?tab=readme-ov-file#platforms-currently-supported)
1920

2021

2122
### Planned features
2223

23-
- Send Wake on LAN magic packets by entering the ip address
24-
- Support for sending json and xml data in request body
24+
- Support for sending json and xml data in the request body
2525

2626
*Planned improvements are labeled with #TODO in the code*
2727

2828

2929
## Configuration
3030

31-
During the integration setup you can change the default http request timeout of 2 seconds to a custom value. You also can deactivate the ssl certificate verification. This is needed for self signed certificates. You can run the setup process again in the integration settings after adding entities to the remote.
31+
During the integration setup you can change the default http request timeout of 2 seconds to a custom value. You also can deactivate the ssl certificate verification. This is needed for self signed ssl certificates. You can run the setup process again in the integration settings to change these settings after adding entities to the remote.
3232

3333
## Usage
3434

@@ -43,27 +43,41 @@ Optional form data in the request body as key/value pairs can be added with a pa
4343
Note that if your url contains a paragraph character you need to url-encode it first (%C2%A7, see https://www.urlencoder.io)
4444

4545

46-
### Setup
46+
## Installation
4747

48-
#### Requirements
48+
### Run on the remote
4949

50-
- Python 3.10 or newer
50+
#### Download integration
51+
52+
Download the tar.gz archive in the assets section from the [latest release](https://github.com/kennymc-c/ucr2-integration-requests/releases/latest)
53+
54+
#### Upload to the remote
55+
56+
TBA
57+
58+
### Run as an external integration on a separate server
59+
60+
#### Bare metal/VM
61+
62+
##### Requirements
63+
64+
- Python 3.11
5165
- Install Libraries:
5266
(using a [virtual environment](https://docs.python.org/3/library/venv.html) is highly recommended)
5367

5468
```shell
5569
pip3 install -r requirements.txt
5670
```
5771

58-
### Run
72+
##### Start the integration
5973

6074
```shell
6175
python3 intg-requests/driver.py
6276
```
6377

64-
### Run as a Docker container
78+
#### Docker container
6579

66-
For the mDNS advertisement to work correctly it's advised to start the integration in the host network (`--net=host`). You can also set the websocket listening port with the environment variable `UC_INTEGRATION_HTTP_PORT`, set the listening interface with `UC_INTEGRATION_INTERFACE` or change the default debug log level with `UC_LOG_LEVEL`. See available [environment variables](https://github.com/unfoldedcircle/integration-python-library#environment-variables)
80+
For the mDNS advertisement (auto discovery of the integration) to work correctly and to be able to use wake-on-lan with an ip address or a hostname instead of a mac address the integration needs to be run in the host network (`--net=host`). You can also set the websocket listening port with the environment variable `UC_INTEGRATION_HTTP_PORT`, set the listening interface with `UC_INTEGRATION_INTERFACE` or change the default debug log level with `UC_LOG_LEVEL`. See available [environment variables](https://github.com/unfoldedcircle/integration-python-library#environment-variables)
6781
in the Python integration library.
6882

6983
All data is mounted to `/usr/src/app`:

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"setup_complete": true}

docker-entry.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22

3-
pip install --no-cache-dir -q -r /usr/src/app/requirements.txt
4-
cd /usr/src/app/intg-requests
5-
python driver.py
3+
cd /usr/src/app
4+
pip install --no-cache-dir -q -r requirements.txt
5+
python intg-requests/driver.py

intg-requests/setup.json renamed to driver.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"driver_id": "requests",
3-
"version": "0.2",
3+
"version": "0.2.0",
44
"release_date": "2024-06-26",
55
"min_core_api": "0.24.3",
66
"name": {

intg-requests/config.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)