Skip to content

Commit

Permalink
build: use latest images of RPi as base images
Browse files Browse the repository at this point in the history
fix(keypad): make keypad compatible with kernel 6.6 by using gpiozero
ci: use latest versions of ruff and pyright
  • Loading branch information
sassanh committed Apr 2, 2024
1 parent 99a4e06 commit 97b4345
Show file tree
Hide file tree
Showing 56 changed files with 217 additions and 147 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration_delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:

- name: Run Tests
run: |
mkdir -p $HOME/.kiv/mods
mkdir -p $HOME/.kivy/mods
poetry run poe test --make-screenshots --cov-report=xml --cov-report=html -n auto --log-level=DEBUG
- name: Collect Window Screenshots
Expand Down Expand Up @@ -290,7 +290,7 @@ jobs:
SUFFIX="${{ matrix.suffix }}"
fi
DASHED_SUFFIX=$(echo $SUFFIX | sed 's/_/-/g')
IMAGE_URL="https://downloads.raspberrypi.com/raspios${SUFFIX}_arm64/images/raspios${SUFFIX}_arm64-2023-12-06/2023-12-05-raspios-bookworm-arm64${DASHED_SUFFIX}.img.xz"
IMAGE_URL="https://downloads.raspberrypi.com/raspios${SUFFIX}_arm64/images/raspios${SUFFIX}_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64${DASHED_SUFFIX}.img.xz"
IMAGE_CHECKSUM=$(curl -s "${IMAGE_URL}.sha256" | awk '{print $1}')
echo "suffix=$SUFFIX" >> "$GITHUB_OUTPUT"
echo "dashed_suffix=$DASHED_SUFFIX" >> "$GITHUB_OUTPUT"
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Version 0.12.3

- build: use latest images of RPi as base images
- fix(keypad): make keypad compatible with kernel 6.6 by using gpiozero
- ci: use latest versions of ruff and pyright

## Version 0.12.2

Expand Down
44 changes: 22 additions & 22 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pytest-asyncio = "^0.23.5.post1"
pytest-cov = "^4.1.0"
pytest-timeout = "^2.3.1"
pytest-xdist = "^3.5.0"
ruff = "^0.3.4"
ruff = "^0.3.5"
tenacity = "^8.2.3"
toml = "^0.10.2"
pytest-mock = "^3.14.0"
Expand Down Expand Up @@ -88,6 +88,7 @@ lint.select = ["ALL"]
lint.ignore = ["INP001", "PLR0911", "D203", "D213"]
lint.fixable = ["ALL"]
lint.unfixable = []
target-version = 'py311'

[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["type", "id"]
Expand Down
1 change: 1 addition & 0 deletions scripts/print_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Prints the version of the ubo_app package."""

import importlib.metadata

print(importlib.metadata.version('ubo_app'), sep='', end='') # noqa: T201
4 changes: 3 additions & 1 deletion tests/fixtures/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
import logging
import sys
import weakref
from typing import TYPE_CHECKING, AsyncGenerator
from typing import TYPE_CHECKING

import pytest

from ubo_app.setup import setup

if TYPE_CHECKING:
from collections.abc import AsyncGenerator

from _pytest.fixtures import SubRequest

from ubo_app.menu import MenuApp
Expand Down
5 changes: 2 additions & 3 deletions tests/fixtures/load_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@

from typing import (
TYPE_CHECKING,
Coroutine,
Generator,
Literal,
Protocol,
Sequence,
cast,
overload,
)

import pytest

if TYPE_CHECKING:
from collections.abc import Coroutine, Generator, Sequence

from tests.conftest import WaitFor


Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

import os
from collections import defaultdict
from typing import TYPE_CHECKING, Any, Generator, cast
from typing import TYPE_CHECKING, Any, cast

import pytest

if TYPE_CHECKING:
from collections.abc import Generator
from pathlib import Path

from _pytest.fixtures import SubRequest
Expand Down
6 changes: 3 additions & 3 deletions tests/monkeypatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class DateTime(datetime.datetime):
@classmethod
def now(cls: type[DateTime], tz: datetime.tzinfo | None = None) -> DateTime:
_ = tz
return DateTime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)
return DateTime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.UTC)

monkeypatch.setattr(datetime, 'datetime', DateTime)

Expand Down Expand Up @@ -188,9 +188,9 @@ async def fake_create_subprocess_exec(
**kwargs: object,
) -> FakeAsyncProcess:
_ = kwargs
if command == '/usr/bin/env' and args == ('systemctl', 'is-enabled', 'sshd'):
if command == '/usr/bin/env' and args == ('systemctl', 'is-enabled', 'ssh'):
return FakeAsyncProcess(output=b'enabled')
if command == '/usr/bin/env' and args == ('systemctl', 'is-active', 'sshd'):
if command == '/usr/bin/env' and args == ('systemctl', 'is-active', 'ssh'):
return FakeAsyncProcess(output=b'active')
if command == '/usr/bin/env' and args == ('systemctl', 'is-enabled', 'lightdm'):
return FakeAsyncProcess(output=b'enabled')
Expand Down
4 changes: 3 additions & 1 deletion tests/utils/import_tracker.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""A module to track imports of other modules."""

from __future__ import annotations

import importlib.abc
import sys
from dataclasses import dataclass
from typing import TYPE_CHECKING, Callable, Sequence
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Callable, Sequence
from types import ModuleType


Expand Down
3 changes: 2 additions & 1 deletion ubo_app/load_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import threading
import traceback
import uuid
from collections.abc import Callable, Sequence
from importlib.machinery import PathFinder, SourceFileLoader
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Sequence, cast
from typing import TYPE_CHECKING, Any, ClassVar, cast

from redux import CombineReducerRegisterAction, ReducerType

Expand Down
5 changes: 4 additions & 1 deletion ubo_app/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
import json
import logging
import sys
from typing import Mapping, cast
from typing import TYPE_CHECKING, cast

if TYPE_CHECKING:
from collections.abc import Mapping

VERBOSE = 5

Expand Down
4 changes: 3 additions & 1 deletion ubo_app/menu_central.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pathlib
import weakref
from functools import cached_property
from typing import TYPE_CHECKING, Sequence
from typing import TYPE_CHECKING

from debouncer import DebounceOptions, debounce
from kivy.clock import Clock, mainthread
Expand All @@ -27,6 +27,8 @@
from .store import autorun, dispatch, subscribe_event

if TYPE_CHECKING:
from collections.abc import Sequence

from kivy.uix.widget import Widget
from ubo_gui.menu.types import Item, Menu

Expand Down
6 changes: 4 additions & 2 deletions ubo_app/menu_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import datetime
from functools import cached_property
from typing import TYPE_CHECKING, Any, Sequence
from typing import TYPE_CHECKING, Any

from kivy.clock import Clock
from kivy.metrics import dp
Expand All @@ -17,6 +17,8 @@
from ubo_app.store import autorun

if TYPE_CHECKING:
from collections.abc import Sequence

from ubo_app.store.status_icons import IconState


Expand Down Expand Up @@ -106,7 +108,7 @@ def clock_widget(self: MenuAppFooter) -> Label:
texture_size[0],
),
)
local_timzone = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo
local_timzone = datetime.datetime.now(datetime.UTC).astimezone().tzinfo

def now() -> datetime.datetime:
return datetime.datetime.now(local_timzone)
Expand Down
3 changes: 2 additions & 1 deletion ubo_app/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Callable, Coroutine, Protocol, TypeAlias
from collections.abc import Callable, Coroutine
from typing import TYPE_CHECKING, Protocol, TypeAlias

if TYPE_CHECKING:
from redux import ReducerType
Expand Down
36 changes: 21 additions & 15 deletions ubo_app/services/000-sound/audio_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,39 @@ async def initialize_audio() -> None:
sink.proplist['alsa.card'],
) == str(self.cardindex):
pulse.sink_default_set(sink)
break
return
logger.error('No audio card found')
except pulsectl.PulseError:
logger.exception('Not able to connect to pulseaudio')
except StopIteration:
logger.exception('No audio card found')
process = await asyncio.create_subprocess_exec(
'/usr/bin/env',
'pulseaudio',
'--kill',
)
await process.wait()
process = await asyncio.create_subprocess_exec(
'/usr/bin/env',
'pulseaudio',
'--start',
)
await process.wait()
except OSError:
logger.exception('Error while setting default sink')
logger.info('Restarting pulseaudio')
process = await asyncio.create_subprocess_exec(
'/usr/bin/env',
'pulseaudio',
'--kill',
)
await process.wait()
process = await asyncio.create_subprocess_exec(
'/usr/bin/env',
'pulseaudio',
'--start',
)
await process.wait()

await asyncio.sleep(5)
await asyncio.sleep(5)
else:
break

create_task(initialize_audio())

def find_respeaker_index(self: AudioManager) -> int:
"""Find the index of the ReSpeaker device."""
for index in range(self.pyaudio.get_device_count()):
info = self.pyaudio.get_device_info_by_index(index)
if not isinstance(info['name'], (int, float)) and 'wm8960' in info['name']:
if not isinstance(info['name'], int | float) and 'wm8960' in info['name']:
logger.debug('ReSpeaker found at index', extra={'index': index})
logger.debug('Device Info', extra={'info': info})
return index
Expand Down
3 changes: 1 addition & 2 deletions ubo_app/services/020-keypad/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
ButtonStatus = Literal['pressed', 'released']


class KeypadError(Exception):
...
class KeypadError(Exception): ...


class ButtonName(StrEnum):
Expand Down
3 changes: 2 additions & 1 deletion ubo_app/services/030-ethernet/ethernet_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

import asyncio
from threading import current_thread
from typing import TYPE_CHECKING, Any, Coroutine, TypeVar
from typing import TYPE_CHECKING, Any, TypeVar

from ubo_app.store.services.ethernet import GlobalEthernetState

if TYPE_CHECKING:
from asyncio.tasks import _FutureLike
from collections.abc import Coroutine


T = TypeVar('T')
Expand Down
5 changes: 4 additions & 1 deletion ubo_app/services/030-ip/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import asyncio
import socket
from collections import defaultdict
from typing import Sequence
from typing import TYPE_CHECKING

import psutil
from constants import INTERNET_STATE_ICON_ID, INTERNET_STATE_ICON_PRIORITY
Expand All @@ -20,6 +20,9 @@
)
from ubo_app.store.status_icons import StatusIconsRegisterAction

if TYPE_CHECKING:
from collections.abc import Sequence


@autorun(lambda state: state.ip.interfaces)
def get_ip_addresses(interfaces: Sequence[IpNetworkInterface]) -> list[SubMenuItem]:
Expand Down
Loading

0 comments on commit 97b4345

Please sign in to comment.