Feat: packaging (#127)
- Add configuration files for packaging - Precommit now uses ruff Co-authored-by: bkfox <thomas bkfox net> Reviewed-on: #127
This commit is contained in:
		@ -62,42 +62,24 @@ class Command(BaseCommand):
 | 
			
		||||
            "--station",
 | 
			
		||||
            type=str,
 | 
			
		||||
            action="append",
 | 
			
		||||
            help="name of the station to monitor instead of monitoring "
 | 
			
		||||
            "all stations",
 | 
			
		||||
            help="name of the station to monitor instead of monitoring " "all stations",
 | 
			
		||||
        )
 | 
			
		||||
        group.add_argument(
 | 
			
		||||
            "-t",
 | 
			
		||||
            "--timeout",
 | 
			
		||||
            type=float,
 | 
			
		||||
            default=Monitor.cancel_timeout.total_seconds() / 60,
 | 
			
		||||
            help="time to wait in MINUTES before canceling a diffusion that "
 | 
			
		||||
            "should have ran but did not. ",
 | 
			
		||||
            help="time to wait in MINUTES before canceling a diffusion that " "should have ran but did not. ",
 | 
			
		||||
        )
 | 
			
		||||
        # TODO: sync-timeout, cancel-timeout
 | 
			
		||||
 | 
			
		||||
    def handle(
 | 
			
		||||
        self,
 | 
			
		||||
        *args,
 | 
			
		||||
        config=None,
 | 
			
		||||
        run=None,
 | 
			
		||||
        monitor=None,
 | 
			
		||||
        station=[],
 | 
			
		||||
        delay=1000,
 | 
			
		||||
        timeout=600,
 | 
			
		||||
        **options
 | 
			
		||||
    ):
 | 
			
		||||
        stations = (
 | 
			
		||||
            Station.objects.filter(name__in=station)
 | 
			
		||||
            if station
 | 
			
		||||
            else Station.objects.all()
 | 
			
		||||
        )
 | 
			
		||||
    def handle(self, *args, config=None, run=None, monitor=None, station=[], delay=1000, timeout=600, **options):
 | 
			
		||||
        stations = Station.objects.filter(name__in=station) if station else Station.objects.all()
 | 
			
		||||
        streamers = [Streamer(station) for station in stations]
 | 
			
		||||
 | 
			
		||||
        for streamer in streamers:
 | 
			
		||||
            if not streamer.outputs:
 | 
			
		||||
                raise RuntimeError(
 | 
			
		||||
                    "Streamer {} has no outputs".format(streamer.id)
 | 
			
		||||
                )
 | 
			
		||||
                raise RuntimeError("Streamer {} has no outputs".format(streamer.id))
 | 
			
		||||
            if config:
 | 
			
		||||
                streamer.make_config()
 | 
			
		||||
            if run:
 | 
			
		||||
@ -106,10 +88,7 @@ class Command(BaseCommand):
 | 
			
		||||
        if monitor:
 | 
			
		||||
            delay = tz.timedelta(milliseconds=delay)
 | 
			
		||||
            timeout = tz.timedelta(minutes=timeout)
 | 
			
		||||
            monitors = [
 | 
			
		||||
                Monitor(streamer, delay, cancel_timeout=timeout)
 | 
			
		||||
                for streamer in streamers
 | 
			
		||||
            ]
 | 
			
		||||
            monitors = [Monitor(streamer, delay, cancel_timeout=timeout) for streamer in streamers]
 | 
			
		||||
 | 
			
		||||
            while not run or streamer.is_running:
 | 
			
		||||
                for monitor in monitors:
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user