resolve flake8 errors

This commit is contained in:
Jan Koppe 2020-04-20 14:51:44 +02:00
parent 97135c90a5
commit bda78d892a
Signed by: thunfisch
GPG Key ID: BE935B0735A2129B
11 changed files with 34 additions and 32 deletions

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -1,3 +1,3 @@
from django.test import TestCase
from django.test import TestCase # noqa
# Create your tests here.

View File

@ -1,3 +1,3 @@
from django.shortcuts import render
from django.shortcuts import render # noqa
# Create your views here.

View File

@ -5,4 +5,4 @@ class SrsConfig(AppConfig):
name = 'srs'
def ready(self):
import srs.signals #noqa
import srs.signals # noqa

View File

@ -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),
),
]

View File

@ -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)

View File

@ -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'])

View File

@ -1,3 +1,3 @@
from django.test import TestCase
from django.test import TestCase # noqa
# Create your tests here.

View File

@ -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')