Feat: packaging (#127)

- Add configuration files for packaging
- Precommit now uses ruff

Co-authored-by: bkfox <thomas bkfox net>
Reviewed-on: rc/aircox#127
This commit is contained in:
Thomas Kairos
2023-10-11 10:58:34 +02:00
parent 5ea092dba6
commit f7a61fe6c0
82 changed files with 332 additions and 935 deletions

View File

@ -47,9 +47,7 @@ class Streamer:
self.id = self.station.slug.replace("-", "_")
self.path = os.path.join(station.path, "station.liq")
self.connector = connector or Connector(
os.path.join(station.path, "station.sock")
)
self.connector = connector or Connector(os.path.join(station.path, "station.sock"))
self.init_sources()
@property
@ -91,9 +89,7 @@ class Streamer:
def init_sources(self):
streams = self.station.program_set.filter(stream__isnull=False)
self.dealer = QueueSource(self, "dealer")
self.sources = [self.dealer] + [
PlaylistSource(self, program=program) for program in streams
]
self.sources = [self.dealer] + [PlaylistSource(self, program=program) for program in streams]
def make_config(self):
"""Make configuration files and directory (and sync sources)"""
@ -128,12 +124,7 @@ class Streamer:
self.source = next(
iter(
sorted(
(
source
for source in self.sources
if source.request_status == "playing"
and source.air_time
),
(source for source in self.sources if source.request_status == "playing" and source.air_time),
key=lambda o: o.air_time,
reverse=True,
)
@ -149,11 +140,7 @@ class Streamer:
if not os.path.exists(self.socket_path):
return
conns = [
conn
for conn in psutil.net_connections(kind="unix")
if conn.laddr == self.socket_path
]
conns = [conn for conn in psutil.net_connections(kind="unix") if conn.laddr == self.socket_path]
for conn in conns:
if conn.pid is not None:
os.kill(conn.pid, signal.SIGKILL)