From ec83aba3bc2c38e7ee7a6b99e3fca37afba9e06a Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Thu, 9 Apr 2020 18:30:16 +0200 Subject: [PATCH] change to yaml --- ffplayout/api/views.py | 34 ++++++++++++++++++++++++--------- ffplayout/ffplayout/settings.py | 2 +- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ffplayout/api/views.py b/ffplayout/api/views.py index c93fec46..aba93e55 100644 --- a/ffplayout/api/views.py +++ b/ffplayout/api/views.py @@ -1,25 +1,32 @@ import os -from django.conf import settings -from rest_framework.views import APIView -from rest_framework.response import Response +import yaml -from .utils import IniParser, SystemStats, get_media_path +from django.conf import settings +from rest_framework.response import Response +from rest_framework.views import APIView +from rest_framework.permissions import AllowAny + +from .utils import SystemStats, get_media_path + + +def read_config(path): + with open(path, 'r') as config_file: + return yaml.safe_load(config_file) class Config(APIView): + permission_classes = (AllowAny,) """ read and write config from ffplayout engine - for reading, endpoint is: http://127.0.0.1:8000/api/config/?config + for reading endpoint is: http://127.0.0.1:8000/api/config/?config """ def get(self, request, *args, **kwargs): if 'config' in request.GET.dict(): if os.path.isfile(settings.FFPLAYOUT_CONFIG): - parser = IniParser() - parser.read(settings.FFPLAYOUT_CONFIG) - - return Response(parser.as_dict()) + yaml = read_config(settings.FFPLAYOUT_CONFIG) + return Response(yaml) else: return Response({ "success": False, @@ -27,6 +34,15 @@ class Config(APIView): else: return Response({"success": False}) + def post(self, request, *args, **kwargs): + if 'config' in request.POST.dict(): + pass + print(request.query_params) + print(args) + print(kwargs) + + return Response({"success": False}) + class Statistics(APIView): """ diff --git a/ffplayout/ffplayout/settings.py b/ffplayout/ffplayout/settings.py index 9bb24a01..1934121b 100644 --- a/ffplayout/ffplayout/settings.py +++ b/ffplayout/ffplayout/settings.py @@ -153,7 +153,7 @@ USE_TZ = True STATIC_URL = '/static/' # path to ffplayout engine config -FFPLAYOUT_CONFIG = '/etc/ffplayout/ffplayout.conf' +FFPLAYOUT_CONFIG = '/etc/ffplayout/ffplayout.yml' # used network interface for statistics: eth0, eno1, etc. NET_INTERFACE = 'br0'