resolve flake8 errors
This commit is contained in:
		
							parent
							
								
									97135c90a5
								
							
						
					
					
						commit
						bda78d892a
					
				| 
						 | 
					@ -4,6 +4,5 @@ from django.apps import AppConfig
 | 
				
			||||||
class RestreamConfig(AppConfig):
 | 
					class RestreamConfig(AppConfig):
 | 
				
			||||||
    name = 'restream'
 | 
					    name = 'restream'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def ready(self):
 | 
					    def ready(self):
 | 
				
			||||||
        import restream.signals  #noqa
 | 
					        import restream.signals  # noqa
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,8 @@ from django.db import models
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create your models here.
 | 
					# Create your models here.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from srs.models import Application, Streamkey
 | 
					from srs.models import Streamkey
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RestreamConfig(models.Model):
 | 
					class RestreamConfig(models.Model):
 | 
				
			||||||
    streamkey = models.ForeignKey(Streamkey, on_delete=models.CASCADE)
 | 
					    streamkey = models.ForeignKey(Streamkey, on_delete=models.CASCADE)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,10 +10,12 @@ from srs.models import Streamkey
 | 
				
			||||||
 | 
					
 | 
				
			||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@receiver(on_unpublish)
 | 
					@receiver(on_unpublish)
 | 
				
			||||||
def callback_on_unpublish(sender, **kwargs):
 | 
					def callback_on_unpublish(sender, **kwargs):
 | 
				
			||||||
    logger.info("stop publish - {}".format(kwargs['name']))
 | 
					    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)
 | 
					@receiver(on_publish)
 | 
				
			||||||
def callback_on_publish(sender, **kwargs):
 | 
					def callback_on_publish(sender, **kwargs):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,3 @@
 | 
				
			||||||
from django.test import TestCase
 | 
					from django.test import TestCase  # noqa
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create your tests here.
 | 
					# Create your tests here.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,3 @@
 | 
				
			||||||
from django.shortcuts import render
 | 
					from django.shortcuts import render  # noqa
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create your views here.
 | 
					# Create your views here.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,4 +5,4 @@ class SrsConfig(AppConfig):
 | 
				
			||||||
    name = 'srs'
 | 
					    name = 'srs'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def ready(self):
 | 
					    def ready(self):
 | 
				
			||||||
        import srs.signals  #noqa
 | 
					        import srs.signals  # noqa
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +14,7 @@ class Migration(migrations.Migration):
 | 
				
			||||||
        migrations.AlterField(
 | 
					        migrations.AlterField(
 | 
				
			||||||
            model_name='streamkey',
 | 
					            model_name='streamkey',
 | 
				
			||||||
            name='key',
 | 
					            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),
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,13 +1,12 @@
 | 
				
			||||||
from django.db import models
 | 
					from django.db import models
 | 
				
			||||||
from django.conf import settings
 | 
					 | 
				
			||||||
import uuid
 | 
					import uuid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from . import signals
 | 
					from . import signals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Application(models.Model):
 | 
					class Application(models.Model):
 | 
				
			||||||
    name = models.CharField(max_length=100, unique=True)
 | 
					    name = models.CharField(max_length=100, unique=True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return self.name
 | 
					        return self.name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,14 +29,14 @@ class Streamkey(models.Model):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_unpublish(self, client_ip, client_id, vhost, param):
 | 
					    def on_unpublish(self, client_ip, client_id, vhost, param):
 | 
				
			||||||
        signals.on_unpublish.send(sender=self.__class__,
 | 
					        signals.on_unpublish.send(sender=self.__class__,
 | 
				
			||||||
                                name=self.name,
 | 
					                                  name=self.name,
 | 
				
			||||||
                                streamkey=self.key,
 | 
					                                  streamkey=self.key,
 | 
				
			||||||
                                app=str(self.application),
 | 
					                                  app=str(self.application),
 | 
				
			||||||
                                client_ip=client_ip,
 | 
					                                  client_ip=client_ip,
 | 
				
			||||||
                                client_id=client_id,
 | 
					                                  client_id=client_id,
 | 
				
			||||||
                                vhost=vhost,
 | 
					                                  vhost=vhost,
 | 
				
			||||||
                                param=param
 | 
					                                  param=param
 | 
				
			||||||
                                )
 | 
					                                  )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return '{}'.format(self.name)
 | 
					        return '{}'.format(self.name)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
from django.dispatch import Signal
 | 
					from django.dispatch import Signal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
on_publish = Signal(providing_args=['application','streamkey','node'])
 | 
					on_publish = Signal(providing_args=['application', 'streamkey', 'node'])
 | 
				
			||||||
on_unpublish = Signal(providing_args=['application','streamkey','node'])
 | 
					on_unpublish = Signal(providing_args=['application', 'streamkey', 'node'])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,3 @@
 | 
				
			||||||
from django.test import TestCase
 | 
					from django.test import TestCase  # noqa
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Create your tests here.
 | 
					# Create your tests here.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										22
									
								
								srs/views.py
								
								
								
								
							
							
						
						
									
										22
									
								
								srs/views.py
								
								
								
								
							| 
						 | 
					@ -2,7 +2,6 @@ import json
 | 
				
			||||||
import logging
 | 
					import logging
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from django.http import HttpResponse
 | 
					from django.http import HttpResponse
 | 
				
			||||||
from django.shortcuts import render
 | 
					 | 
				
			||||||
from django.views.decorators.csrf import csrf_exempt
 | 
					from django.views.decorators.csrf import csrf_exempt
 | 
				
			||||||
from django.core.exceptions import ObjectDoesNotExist
 | 
					from django.core.exceptions import ObjectDoesNotExist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +9,7 @@ from . import models
 | 
				
			||||||
 | 
					
 | 
				
			||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@csrf_exempt
 | 
					@csrf_exempt
 | 
				
			||||||
def callback(request):
 | 
					def callback(request):
 | 
				
			||||||
    if request.method != 'POST':
 | 
					    if request.method != 'POST':
 | 
				
			||||||
| 
						 | 
					@ -34,17 +34,17 @@ def callback(request):
 | 
				
			||||||
        return HttpResponse('1', status=401)
 | 
					        return HttpResponse('1', status=401)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if json_data.get('action') == 'on_publish':
 | 
					    if json_data.get('action') == 'on_publish':
 | 
				
			||||||
      streamkey.on_publish(client_ip=client_ip,
 | 
					        streamkey.on_publish(client_ip=client_ip,
 | 
				
			||||||
                         client_id=client_id,
 | 
					                             client_id=client_id,
 | 
				
			||||||
                         vhost=vhost,
 | 
					                             vhost=vhost,
 | 
				
			||||||
                         param=param
 | 
					                             param=param
 | 
				
			||||||
                         )
 | 
					                             )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if json_data.get('action') == 'on_unpublish':
 | 
					    if json_data.get('action') == 'on_unpublish':
 | 
				
			||||||
      streamkey.on_unpublish(client_ip=client_ip,
 | 
					        streamkey.on_unpublish(client_ip=client_ip,
 | 
				
			||||||
                         client_id=client_id,
 | 
					                               client_id=client_id,
 | 
				
			||||||
                         vhost=vhost,
 | 
					                               vhost=vhost,
 | 
				
			||||||
                         param=param
 | 
					                               param=param
 | 
				
			||||||
                         )
 | 
					                               )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return HttpResponse('0')
 | 
					    return HttpResponse('0')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue