From bda78d892a59f11fb246fd598e220f0a6c1a5e5d Mon Sep 17 00:00:00 2001 From: Jan Koppe Date: Mon, 20 Apr 2020 14:51:44 +0200 Subject: [PATCH] resolve flake8 errors --- restream/apps.py | 3 +-- restream/models.py | 3 ++- restream/signals.py | 4 +++- restream/tests.py | 2 +- restream/views.py | 2 +- srs/apps.py | 2 +- srs/migrations/0005_auto_20200413_1745.py | 3 ++- srs/models.py | 19 +++++++++---------- srs/signals.py | 4 ++-- srs/tests.py | 2 +- srs/views.py | 22 +++++++++++----------- 11 files changed, 34 insertions(+), 32 deletions(-) diff --git a/restream/apps.py b/restream/apps.py index 7084b08..fbd9a02 100644 --- a/restream/apps.py +++ b/restream/apps.py @@ -4,6 +4,5 @@ from django.apps import AppConfig class RestreamConfig(AppConfig): name = 'restream' - def ready(self): - import restream.signals #noqa + import restream.signals # noqa diff --git a/restream/models.py b/restream/models.py index 79dde7e..d3d2828 100644 --- a/restream/models.py +++ b/restream/models.py @@ -2,7 +2,8 @@ from django.db import models # Create your models here. -from srs.models import Application, Streamkey +from srs.models import Streamkey + class RestreamConfig(models.Model): streamkey = models.ForeignKey(Streamkey, on_delete=models.CASCADE) diff --git a/restream/signals.py b/restream/signals.py index cba3bf6..8bb481a 100644 --- a/restream/signals.py +++ b/restream/signals.py @@ -10,10 +10,12 @@ from srs.models import Streamkey logger = logging.getLogger(__name__) + @receiver(on_unpublish) def callback_on_unpublish(sender, **kwargs): logger.info("stop publish - {}".format(kwargs['name'])) - celery.send_task('main.stop_restream', kwargs={'name':kwargs['name']}) + celery.send_task('main.stop_restream', kwargs={'name': kwargs['name']}) + @receiver(on_publish) def callback_on_publish(sender, **kwargs): diff --git a/restream/tests.py b/restream/tests.py index 7ce503c..9a30df3 100644 --- a/restream/tests.py +++ b/restream/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +from django.test import TestCase # noqa # Create your tests here. diff --git a/restream/views.py b/restream/views.py index 91ea44a..6100593 100644 --- a/restream/views.py +++ b/restream/views.py @@ -1,3 +1,3 @@ -from django.shortcuts import render +from django.shortcuts import render # noqa # Create your views here. diff --git a/srs/apps.py b/srs/apps.py index 0f3bec1..8dd0da0 100644 --- a/srs/apps.py +++ b/srs/apps.py @@ -5,4 +5,4 @@ class SrsConfig(AppConfig): name = 'srs' def ready(self): - import srs.signals #noqa + import srs.signals # noqa diff --git a/srs/migrations/0005_auto_20200413_1745.py b/srs/migrations/0005_auto_20200413_1745.py index 00863d0..08c808b 100644 --- a/srs/migrations/0005_auto_20200413_1745.py +++ b/srs/migrations/0005_auto_20200413_1745.py @@ -14,6 +14,7 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='streamkey', name='key', - field=models.CharField(default=uuid.UUID('b5777854-4533-49dc-b38d-69738d8844d6'), max_length=64, unique=True), + field=models.CharField(default=uuid.UUID('b5777854-4533-49dc-b38d-69738d8844d6'), + max_length=64, unique=True), ), ] diff --git a/srs/models.py b/srs/models.py index e6bcfa8..3f54d3a 100644 --- a/srs/models.py +++ b/srs/models.py @@ -1,13 +1,12 @@ from django.db import models -from django.conf import settings import uuid from . import signals + class Application(models.Model): name = models.CharField(max_length=100, unique=True) - def __str__(self): return self.name @@ -30,14 +29,14 @@ class Streamkey(models.Model): def on_unpublish(self, client_ip, client_id, vhost, param): signals.on_unpublish.send(sender=self.__class__, - name=self.name, - streamkey=self.key, - app=str(self.application), - client_ip=client_ip, - client_id=client_id, - vhost=vhost, - param=param - ) + name=self.name, + streamkey=self.key, + app=str(self.application), + client_ip=client_ip, + client_id=client_id, + vhost=vhost, + param=param + ) def __str__(self): return '{}'.format(self.name) diff --git a/srs/signals.py b/srs/signals.py index 8b692ef..2618e9f 100644 --- a/srs/signals.py +++ b/srs/signals.py @@ -1,4 +1,4 @@ from django.dispatch import Signal -on_publish = Signal(providing_args=['application','streamkey','node']) -on_unpublish = Signal(providing_args=['application','streamkey','node']) +on_publish = Signal(providing_args=['application', 'streamkey', 'node']) +on_unpublish = Signal(providing_args=['application', 'streamkey', 'node']) diff --git a/srs/tests.py b/srs/tests.py index 7ce503c..9a30df3 100644 --- a/srs/tests.py +++ b/srs/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +from django.test import TestCase # noqa # Create your tests here. diff --git a/srs/views.py b/srs/views.py index 39a7d27..0b2c92a 100644 --- a/srs/views.py +++ b/srs/views.py @@ -2,7 +2,6 @@ import json import logging from django.http import HttpResponse -from django.shortcuts import render from django.views.decorators.csrf import csrf_exempt from django.core.exceptions import ObjectDoesNotExist @@ -10,6 +9,7 @@ from . import models logger = logging.getLogger(__name__) + @csrf_exempt def callback(request): if request.method != 'POST': @@ -34,17 +34,17 @@ def callback(request): return HttpResponse('1', status=401) if json_data.get('action') == 'on_publish': - streamkey.on_publish(client_ip=client_ip, - client_id=client_id, - vhost=vhost, - param=param - ) + streamkey.on_publish(client_ip=client_ip, + client_id=client_id, + vhost=vhost, + param=param + ) if json_data.get('action') == 'on_unpublish': - streamkey.on_unpublish(client_ip=client_ip, - client_id=client_id, - vhost=vhost, - param=param - ) + streamkey.on_unpublish(client_ip=client_ip, + client_id=client_id, + vhost=vhost, + param=param + ) return HttpResponse('0')