Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
albaintor committed Jul 13, 2024
1 parent 7ca02d3 commit 0cd8b54
Show file tree
Hide file tree
Showing 14 changed files with 664 additions and 257 deletions.
53 changes: 53 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Bug report
description: Create a report to help us improve
title: '<title>'
labels: [bug]

body:
- type: markdown
attributes:
value: |
Please check the existing issues first to see if the bug has already been recorded.
If you have more information about an existing bug, please add it as a comment and don't open a new issue.
Thank you!
- type: textarea
attributes:
label: Description
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
attributes:
label: How to Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. ...
2. ...
3. See error
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: input
id: intg_version
attributes:
label: Integration version
description: You can find the integration version in driver.json or in the UI under Settings/Integrations
placeholder: ex. v0.4.5
validations:
required: false
- type: textarea
attributes:
label: Additional context
description: |
Add any other context about the problem here. Otherwise you can ignore this section.
How has this issue affected you? What are you trying to accomplish?
Providing context helps us come up with a solution that is most useful in the real world
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: false
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
blank_issues_enabled: false
contact_links:
- name: Unfolded Circle Community Forum
url: https://unfolded.community/
about: Please ask and answer questions here.
- name: Unfolded Circle Discord Channel
url: https://unfolded.chat/
about: Chat with the community and for asking questions.
- name: Unfolded Circle Contact Form
url: https://unfoldedcircle.com/contact
about: Write us a message on our website.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Feature request
description: Suggest an idea
title: '<title>'
labels: [enhancement]

body:
- type: markdown
attributes:
value: |
Please check the existing issues first to see if your feature request has already been recorded.
- type: textarea
attributes:
label: Description
description: A clear and concise description of what the feature request is about.
validations:
required: true
- type: textarea
attributes:
label: Additional context
description: |
Add any other context or screenshots about the feature request here.
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: false
146 changes: 146 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# GitHub Action to build a self-contained binary of the Android TV Python driver
---
name: "Build & Release"

on:
push:
branches: [main]
tags:
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches: [main]
types: [opened, synchronize, reopened]

env:
INTG_NAME: zidoo
HASH_FILENAME: uc-intg-zidoo.hash
# Python version to use in the builder image. See https://hub.docker.com/r/unfoldedcircle/r2-pyinstaller for possible versions.
PYTHON_VER: 3.11.6-0.2.0

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# History of 200 should be more than enough to calculate commit count since last release tag.
fetch-depth: 200

- name: Fetch all tags to determine version
run: |
git fetch origin +refs/tags/*:refs/tags/*
echo "VERSION=$(git describe --match "v[0-9]*" --tags HEAD --always)" >> $GITHUB_ENV
- name: Verify driver.json version for release build
if: contains(github.ref, 'tags/v')
run: |
DRIVER_VERSION="v$(jq .version -r driver.json)"
if [ "${{ env.VERSION }}" != "$DRIVER_VERSION" ]; then
echo "Version in driver.json ($DRIVER_VERSION) doesn't match git version tag (${{ env.VERSION }})!"
exit 1
fi
- name: Prepare
run: |
sudo apt-get update && sudo apt-get install -y qemu binfmt-support qemu-user-static
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
echo "Starting pyinstaller build"
docker run --rm --name builder \
--platform=aarch64 \
--user=$(id -u):$(id -g) \
-v ${GITHUB_WORKSPACE}:/workspace \
docker.io/unfoldedcircle/r2-pyinstaller:${PYTHON_VER} \
bash -c \
"cd /workspace && \
python -m pip install -r requirements.txt && \
pyinstaller --clean --onefile --name intg-zidoo intg-zidoo/driver.py"
- name: Add version
run: |
mkdir -p artifacts
cd artifacts
echo ${{ env.VERSION }} > version.txt
- name: Prepare artifacts
shell: bash
run: |
cp dist/intg-zidoo artifacts/
cp driver.json artifacts/
cp orange.png artifacts/
echo "ARTIFACT_NAME=uc-intg-${{ env.INTG_NAME }}-${{ env.VERSION }}-aarch64" >> $GITHUB_ENV
- name: Create upload artifact
shell: bash
run: |
tar czvf ${{ env.ARTIFACT_NAME }}.tar.gz -C ${GITHUB_WORKSPACE}/artifacts .
ls -lah
- uses: actions/upload-artifact@v4
id: upload_artifact
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}.tar.gz
if-no-files-found: error
retention-days: 3

release:
name: Create Release
if: github.ref == 'refs/heads/main' || contains(github.ref, 'tags/v')
runs-on: ubuntu-latest
needs: [build]

steps:
- name: Download build artifacts
uses: actions/download-artifact@v4

- name: Extract build archives from downloaded files
run: |
ls -R
# extract tar.gz build archives from downloaded artifacts
# (wrapped in tar from actions/upload-artifact, then extracted into a directory by actions/download-artifact)
for D in *
do if [ -d "${D}" ]; then
mv $D/* ./
fi
done;
# Use a common timestamp for all matrix build artifacts
- name: Get timestamp
run: |
echo "TIMESTAMP=$(date +"%Y%m%d_%H%M%S")" >> $GITHUB_ENV
# Add timestamp to development builds
- name: Create GitHub development build archives
if: "!contains(github.ref, 'tags/v')"
run: |
# append timestamp
for filename in *.tar.gz; do mv $filename "$(basename $filename .tar.gz)-${{ env.TIMESTAMP }}.tar.gz"; done;
for filename in *.tar.gz; do echo "sha256 `sha256sum $filename`" >> ${{ env.HASH_FILENAME }}; done;
- name: Create Pre-Release
uses: "marvinpinto/action-automatic-releases@latest"
if: "!contains(github.ref, 'tags/v')"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: |
*.tar.gz
${{ env.HASH_FILENAME }}
- name: Create GitHub release archives
if: "contains(github.ref, 'tags/v')"
run: |
for filename in *.tar.gz; do echo "sha256 `sha256sum $filename`" >> ${{ env.HASH_FILENAME }}; done;
- name: Create Release
uses: "marvinpinto/action-automatic-releases@latest"
if: "contains(github.ref, 'tags/v')"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
*.tar.gz
${{ env.HASH_FILENAME }}
52 changes: 52 additions & 0 deletions .github/workflows/python-code-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Check Python code formatting

on:
push:
paths:
- 'intg-zidoo/**'
- 'requirements.txt'
- 'test-requirements.txt'
- 'tests/**'
- '.github/**/*.yml'
- '.pylintrc'
- 'pyproject.toml'
pull_request:
branches: [main]
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-22.04

name: Check Python code formatting
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install pip
run: |
python -m pip install --upgrade pip
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f test-requirements.txt ]; then pip install -r test-requirements.txt; fi
- name: Analyzing the code with pylint
run: |
python -m pylint intg-zidoo
- name: Lint with flake8
run: |
python -m flake8 intg-zidoo --count --show-source --statistics
- name: Check code formatting with isort
run: |
python -m isort intg-zidoo/. --check --verbose
- name: Check code formatting with black
run: |
python -m black intg-zidoo --check --diff --verbose --line-length 120
2 changes: 2 additions & 0 deletions intg-zidoo/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ def device_from_entity_id(entity_id: str) -> str | None:
class DeviceInstance:
"""Orange TV device configuration."""

# pylint: disable = W0622
id: str
name: str
address: str
net_mac_address: str
wifi_mac_address: str

def __init__(self, id, name, address, net_mac_address=None, wifi_mac_address=None):
"""Initialize device instance config."""
self.id = id
self.name = name
self.address = address
Expand Down
10 changes: 9 additions & 1 deletion intg-zidoo/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@
1: MediaType.MUSIC, # music
2: MediaType.VIDEO, # video
# 3: MediaType.IMAGE, # image
# 4: 'text', # 5: 'apk', # 6: 'pdf', # 7: 'document', # 8: 'spreadsheet', # 9: 'presentation', # 10: 'web', # 11: 'archive' , # 12: 'other'
# 4: 'text',
# 5: 'apk',
# 6: 'pdf',
# 7: 'document',
# 8: 'spreadsheet',
# 9: 'presentation',
# 10: 'web',
# 11: 'archive' ,
# 12: 'other'
1000: MEDIA_TYPE_FILE, # hhd
1001: MEDIA_TYPE_FILE, # usb
1002: MEDIA_TYPE_FILE, # usb
Expand Down
Loading

0 comments on commit 0cd8b54

Please sign in to comment.