Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:
python -m pip install .
- name: Test with pytest
run: |
pytest
PY_VERSION=${{ matrix.python-version }} pytest
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ repos:
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.0
rev: v0.15.0
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this is needed anymore, and the hook has been renamed (ruff-check IIRC)

# Run the formatter.
- id: ruff-format
- repo: https://github.com/tox-dev/pyproject-fmt
rev: "v2.12.1"
hooks:
- id: pyproject-fmt

#- repo: https://github.com/pre-commit/mirrors-clang-format
# rev: v15.0.7
# hooks:
Expand Down
6 changes: 4 additions & 2 deletions server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM python:3.11 AS build
ARG PY_VERSION=3.9

FROM python:$PY_VERSION AS build

WORKDIR /home/recceiver

Expand All @@ -8,7 +10,7 @@ RUN python -m venv venv

RUN venv/bin/python -m pip install ./server

FROM python:3.11-alpine
FROM python:$PY_VERSION-alpine

WORKDIR /home/recceiver

Expand Down
5 changes: 4 additions & 1 deletion server/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ include:
- docker/cf-compose.yml
services:
recc:
build: .
build:
context: .
args:
PY_VERSION: ${PY_VERSION:-3.9}
depends_on:
cf:
condition: service_healthy
Expand Down
57 changes: 33 additions & 24 deletions server/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,45 +1,54 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
requires = [ "setuptools" ]

[project]
name="recceiver"
name = "recceiver"
version = "1.5"
description = "resync server"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

readme = "README.md"
authors = [
{name = "Michael Davidsaver", email = "mdavidsaver@gmail.com"},
{ name = "Michael Davidsaver", email = "mdavidsaver@gmail.com" },
]
description="resync server"
version="1.5"
readme = "README.md"
requires-python = ">=3.6"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"dataclasses; python_version < '3.7'",
"requests",
"twisted",
"channelfinder @ https://github.com/ChannelFinder/pyCFClient/archive/refs/tags/v3.0.0.zip"
"channelfinder @ https://github.com/ChannelFinder/pyCFClient/archive/refs/tags/v3.0.0.zip",
"dataclasses; python_version<'3.7'",
"requests",
"twisted",
]

[project.optional-dependencies]
test = ["pytest", "testcontainers>=4"]

[project.urls]
Repository="https://github.com/mdavidsaver/recsync"
optional-dependencies.test = [ "pytest", "testcontainers>=4" ]
urls.Repository = "https://github.com/mdavidsaver/recsync"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong?


[tool.setuptools]
packages = ["recceiver", "twisted.plugins"]
packages = [ "recceiver", "twisted.plugins" ]
include-package-data = true

[tool.setuptools.package-data]
twisted = ["plugins/recceiver_plugin.py"]

[tool.pytest.ini_options]
log_cli = true
log_cli_level = "DEBUG"
twisted = [ "plugins/recceiver_plugin.py" ]

[tool.ruff]
line-length = 120
target-version = "py39"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't mesh well with your attempt to externalise python version into a variable


[tool.ruff.lint]
line-length = 120
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
# McCabe complexity (`C901`) by default.
select = ["E", "F", "I"]
lint.select = [ "E", "F", "I" ]

[tool.pytest.ini_options]
log_cli = true
log_cli_level = "DEBUG"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this as default?

6 changes: 3 additions & 3 deletions server/recceiver/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import logging
import random

from zope.interface import implementer

from twisted import plugin
from twisted.application import service
from twisted.internet import defer, pollreactor
from twisted.internet.error import CannotListenError
from twisted.python import log, usage
from zope.interface import implementer

from twisted import plugin

from .announce import Announcer
from .processors import ProcessorController
Expand Down
7 changes: 3 additions & 4 deletions server/recceiver/cfstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

from channelfinder import ChannelFinderClient
from requests import ConnectionError, RequestException
from zope.interface import implementer

from twisted.application import service
from twisted.internet import defer
from twisted.internet.defer import DeferredLock
from twisted.internet.threads import deferToThread
from zope.interface import implementer

from . import interfaces
from .interfaces import CommitTransaction
Expand All @@ -31,7 +30,7 @@
DEFAULT_QUERY_LIMIT = 10_000


class PVStatus(enum.StrEnum):
class PVStatus(str, enum.Enum):
"""PV Status values."""

ACTIVE = "Active"
Expand Down Expand Up @@ -170,7 +169,7 @@ class RecordInfo:
aliases: List[str] = field(default_factory=list)


class CFPropertyName(enum.StrEnum):
class CFPropertyName(str, enum.Enum):
"""Standard property names used in Channelfinder."""

HOSTNAME = "hostName"
Expand Down
3 changes: 1 addition & 2 deletions server/recceiver/dbstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import itertools
import logging

from zope.interface import implementer

from twisted.application import service
from twisted.enterprise import adbapi as db
from twisted.internet import defer
from zope.interface import implementer

from . import interfaces

Expand Down
3 changes: 1 addition & 2 deletions server/recceiver/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from dataclasses import dataclass
from typing import Dict, List, Set, Tuple

from zope.interface import Attribute, Interface

from twisted.application import service
from zope.interface import Attribute, Interface


class ITransaction(Interface):
Expand Down
1 change: 0 additions & 1 deletion server/recceiver/mock_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from requests import HTTPError

from twisted.internet.address import IPv4Address


Expand Down
4 changes: 2 additions & 2 deletions server/recceiver/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from configparser import ConfigParser as Parser
from os.path import expanduser

from twisted.application import service
from twisted.internet import defer, task
from zope.interface import implementer

from twisted import plugin
from twisted.application import service
from twisted.internet import defer, task

from . import interfaces

Expand Down
3 changes: 1 addition & 2 deletions server/recceiver/recast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
import sys
import time

from zope.interface import implementer

from twisted.internet import defer, protocol
from twisted.protocols import stateful
from zope.interface import implementer

from .interfaces import ITransaction

Expand Down
2 changes: 1 addition & 1 deletion server/tests/test_bash_ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from typing import Optional

from channelfinder import ChannelFinderClient
from docker.models.containers import Container
from testcontainers.compose import DockerCompose

from docker import DockerClient
from docker.models.containers import Container

from .client_checks import (
BASE_IOC_CHANNEL_COUNT,
Expand Down
Loading