mirror of
https://github.com/fastogt/fastocloud_admin.git
synced 2025-03-09 23:38:52 +00:00
Review
This commit is contained in:
parent
6f7ecd9a4e
commit
4b1911695f
6 changed files with 26 additions and 26 deletions
|
@ -3,7 +3,6 @@ import struct
|
||||||
import json
|
import json
|
||||||
import threading
|
import threading
|
||||||
import select
|
import select
|
||||||
import zlib
|
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from app.client.client_constants import Commands, ClientStatus
|
from app.client.client_constants import Commands, ClientStatus
|
||||||
|
|
|
@ -3,7 +3,7 @@ from flask_babel import lazy_gettext
|
||||||
from wtforms.fields import StringField, FieldList, IntegerField, FormField, FloatField
|
from wtforms.fields import StringField, FieldList, IntegerField, FormField, FloatField
|
||||||
from wtforms.validators import InputRequired, Length, NumberRange
|
from wtforms.validators import InputRequired, Length, NumberRange
|
||||||
|
|
||||||
from app.constants import MIN_URL_LENGTH, MAX_URL_LENGTH, MIN_ALPHA, MAX_ALPHA, MIN_PATH_LENGTH, MAX_PATH_LENGTH
|
import app.constants as constants
|
||||||
from app.common_entries import Rational, Size, Logo, InputUrls, InputUrl, OutputUrls, OutputUrl, HostAndPort
|
from app.common_entries import Rational, Size, Logo, InputUrls, InputUrl, OutputUrls, OutputUrl, HostAndPort
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class UrlForm(Form):
|
||||||
validators=[InputRequired()], render_kw={'readonly': 'true'})
|
validators=[InputRequired()], render_kw={'readonly': 'true'})
|
||||||
uri = StringField(lazy_gettext(u'Url:'),
|
uri = StringField(lazy_gettext(u'Url:'),
|
||||||
validators=[InputRequired(),
|
validators=[InputRequired(),
|
||||||
Length(min=MIN_URL_LENGTH, max=MAX_URL_LENGTH)])
|
Length(min=constants.MIN_URL_LENGTH, max=constants.MAX_URL_LENGTH)])
|
||||||
|
|
||||||
|
|
||||||
class InputUrlForm(UrlForm):
|
class InputUrlForm(UrlForm):
|
||||||
|
@ -33,7 +33,7 @@ class InputUrlsForm(Form):
|
||||||
class OutputUrlForm(UrlForm):
|
class OutputUrlForm(UrlForm):
|
||||||
http_root = StringField(lazy_gettext(u'Http root:'),
|
http_root = StringField(lazy_gettext(u'Http root:'),
|
||||||
validators=[InputRequired(),
|
validators=[InputRequired(),
|
||||||
Length(min=MIN_PATH_LENGTH, max=MAX_PATH_LENGTH)],
|
Length(min=constants.MIN_PATH_LENGTH, max=constants.MAX_PATH_LENGTH)],
|
||||||
render_kw={'readonly': 'true'})
|
render_kw={'readonly': 'true'})
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class LogoForm(Form):
|
||||||
x = IntegerField(lazy_gettext(u'Pos x:'), validators=[InputRequired()])
|
x = IntegerField(lazy_gettext(u'Pos x:'), validators=[InputRequired()])
|
||||||
y = IntegerField(lazy_gettext(u'Pos y:'), validators=[InputRequired()])
|
y = IntegerField(lazy_gettext(u'Pos y:'), validators=[InputRequired()])
|
||||||
alpha = FloatField(lazy_gettext(u'Alpha:'),
|
alpha = FloatField(lazy_gettext(u'Alpha:'),
|
||||||
validators=[InputRequired(), NumberRange(MIN_ALPHA, MAX_ALPHA)])
|
validators=[InputRequired(), NumberRange(constants.MIN_ALPHA, constants.MAX_ALPHA)])
|
||||||
|
|
||||||
def get_data(self) -> Logo:
|
def get_data(self) -> Logo:
|
||||||
logo = Logo()
|
logo = Logo()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from mongoengine import EmbeddedDocument, StringField
|
from mongoengine import EmbeddedDocument, StringField
|
||||||
from app.constants import DEFAULT_LOCALE
|
import app.constants as constants
|
||||||
|
|
||||||
|
|
||||||
class Settings(EmbeddedDocument):
|
class Settings(EmbeddedDocument):
|
||||||
locale = StringField(default=DEFAULT_LOCALE)
|
locale = StringField(default=constants.DEFAULT_LOCALE)
|
||||||
|
|
|
@ -5,7 +5,7 @@ from flask_mail import Message
|
||||||
from flask_babel import gettext
|
from flask_babel import gettext
|
||||||
from itsdangerous import SignatureExpired, URLSafeTimedSerializer
|
from itsdangerous import SignatureExpired, URLSafeTimedSerializer
|
||||||
|
|
||||||
from app.constants import AVAILABLE_LOCALES_PAIRS, DEFAULT_LOCALE, AVAILABLE_LOCALES
|
import app.constants as constants
|
||||||
from app.utils.utils import is_valid_email
|
from app.utils.utils import is_valid_email
|
||||||
from app import app, mail, login_manager, babel
|
from app import app, mail, login_manager, babel
|
||||||
from app.home.user_loging_manager import User, login_user_wrap
|
from app.home.user_loging_manager import User, login_user_wrap
|
||||||
|
@ -29,6 +29,7 @@ def send_email(email: str, subject: str, message: str):
|
||||||
|
|
||||||
def post_login(form: SigninForm):
|
def post_login(form: SigninForm):
|
||||||
if not form.validate_on_submit():
|
if not form.validate_on_submit():
|
||||||
|
flash_error(form.errors)
|
||||||
return render_template('home/login.html', form=form)
|
return render_template('home/login.html', form=form)
|
||||||
|
|
||||||
check_user = User.objects(email=form.email.data).first()
|
check_user = User.objects(email=form.email.data).first()
|
||||||
|
@ -58,7 +59,7 @@ class HomeView(FlaskView):
|
||||||
self._confirm_link_generator = URLSafeTimedSerializer(app.config['SECRET_KEY'])
|
self._confirm_link_generator = URLSafeTimedSerializer(app.config['SECRET_KEY'])
|
||||||
|
|
||||||
def index(self):
|
def index(self):
|
||||||
languages = AVAILABLE_LOCALES_PAIRS
|
languages = constants.AVAILABLE_LOCALES_PAIRS
|
||||||
return render_template('index.html', languages=languages)
|
return render_template('index.html', languages=languages)
|
||||||
|
|
||||||
@route('/robots.txt')
|
@route('/robots.txt')
|
||||||
|
@ -82,8 +83,8 @@ class HomeView(FlaskView):
|
||||||
return render_template('contact.html', form=form)
|
return render_template('contact.html', form=form)
|
||||||
|
|
||||||
@route('/language/<language>')
|
@route('/language/<language>')
|
||||||
def set_language(self, language=DEFAULT_LOCALE):
|
def set_language(self, language=constants.DEFAULT_LOCALE):
|
||||||
founded = next((x for x in AVAILABLE_LOCALES if x == language), None)
|
founded = next((x for x in constants.AVAILABLE_LOCALES if x == language), None)
|
||||||
if founded:
|
if founded:
|
||||||
session['language'] = founded
|
session['language'] = founded
|
||||||
|
|
||||||
|
@ -130,6 +131,7 @@ class HomeView(FlaskView):
|
||||||
form = SignupForm()
|
form = SignupForm()
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
if not form.validate_on_submit():
|
if not form.validate_on_submit():
|
||||||
|
flash_error(form.errors)
|
||||||
return render_template('home/register.html', form=form)
|
return render_template('home/register.html', form=form)
|
||||||
|
|
||||||
email = form.email.data
|
email = form.email.data
|
||||||
|
@ -178,7 +180,7 @@ def get_locale():
|
||||||
# otherwise try to guess the language from the user accept
|
# otherwise try to guess the language from the user accept
|
||||||
# header the browser transmits. We support de/fr/en in this
|
# header the browser transmits. We support de/fr/en in this
|
||||||
# example. The best match wins.
|
# example. The best match wins.
|
||||||
return request.accept_languages.best_match(AVAILABLE_LOCALES)
|
return request.accept_languages.best_match(constants.AVAILABLE_LOCALES)
|
||||||
|
|
||||||
|
|
||||||
def page_not_found(e):
|
def page_not_found(e):
|
||||||
|
|
|
@ -5,8 +5,7 @@ from app.client.client_constants import Commands, ClientStatus
|
||||||
|
|
||||||
from app.service.service_entry import ServiceSettings
|
from app.service.service_entry import ServiceSettings
|
||||||
from app.service.stream_handler import IStreamHandler
|
from app.service.stream_handler import IStreamHandler
|
||||||
from app.constants import DEFAULT_SERVICE_LOG_PATH_TEMPLATE_3SIS, DEFAULT_STREAM_LOG_PATH_TEMPLATE_3SIS, \
|
import app.constants as constants
|
||||||
DEFAULT_STREAM_PIPELINE_PATH_TEMPLATE_3SIS
|
|
||||||
|
|
||||||
|
|
||||||
class ServiceClient(IClientHandler):
|
class ServiceClient(IClientHandler):
|
||||||
|
@ -16,15 +15,15 @@ class ServiceClient(IClientHandler):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_log_service_path(host: str, port: int, sid: str):
|
def get_log_service_path(host: str, port: int, sid: str):
|
||||||
return DEFAULT_SERVICE_LOG_PATH_TEMPLATE_3SIS.format(host, port, sid)
|
return constants.DEFAULT_SERVICE_LOG_PATH_TEMPLATE_3SIS.format(host, port, sid)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_log_stream_path(host: str, port: int, stream_id: str):
|
def get_log_stream_path(host: str, port: int, stream_id: str):
|
||||||
return DEFAULT_STREAM_LOG_PATH_TEMPLATE_3SIS.format(host, port, stream_id)
|
return constants.DEFAULT_STREAM_LOG_PATH_TEMPLATE_3SIS.format(host, port, stream_id)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_pipeline_stream_path(host: str, port: int, stream_id: str):
|
def get_pipeline_stream_path(host: str, port: int, stream_id: str):
|
||||||
return DEFAULT_STREAM_PIPELINE_PATH_TEMPLATE_3SIS.format(host, port, stream_id)
|
return constants.DEFAULT_STREAM_PIPELINE_PATH_TEMPLATE_3SIS.format(host, port, stream_id)
|
||||||
|
|
||||||
def __init__(self, handler: IStreamHandler, settings: ServiceSettings):
|
def __init__(self, handler: IStreamHandler, settings: ServiceSettings):
|
||||||
self._request_id = 0
|
self._request_id = 0
|
||||||
|
|
|
@ -4,7 +4,7 @@ from flask_classy import FlaskView, route
|
||||||
from flask import render_template, request, jsonify
|
from flask import render_template, request, jsonify
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
|
||||||
from app.constants import StreamType
|
import app.constants as constants
|
||||||
from app import get_runtime_stream_folder
|
from app import get_runtime_stream_folder
|
||||||
from app.stream.stream_forms import EncodeStreamForm, RelayStreamForm, TimeshiftRecorderStreamForm, CatchupStreamForm, \
|
from app.stream.stream_forms import EncodeStreamForm, RelayStreamForm, TimeshiftRecorderStreamForm, CatchupStreamForm, \
|
||||||
TimeshiftPlayerStreamForm, TestLifeStreamForm, VodEncodeStreamForm, VodRelayStreamForm
|
TimeshiftPlayerStreamForm, TestLifeStreamForm, VodEncodeStreamForm, VodRelayStreamForm
|
||||||
|
@ -228,7 +228,7 @@ class StreamView(FlaskView):
|
||||||
stream = server.find_stream_by_id(sid)
|
stream = server.find_stream_by_id(sid)
|
||||||
if stream:
|
if stream:
|
||||||
type = stream.get_type()
|
type = stream.get_type()
|
||||||
if type == StreamType.RELAY:
|
if type == constants.StreamType.RELAY:
|
||||||
form = RelayStreamForm(obj=stream)
|
form = RelayStreamForm(obj=stream)
|
||||||
|
|
||||||
if request.method == 'POST' and form.validate_on_submit():
|
if request.method == 'POST' and form.validate_on_submit():
|
||||||
|
@ -238,7 +238,7 @@ class StreamView(FlaskView):
|
||||||
|
|
||||||
return render_template('stream/relay/edit.html', form=form,
|
return render_template('stream/relay/edit.html', form=form,
|
||||||
feedback_dir=stream.generate_feedback_dir())
|
feedback_dir=stream.generate_feedback_dir())
|
||||||
elif type == StreamType.ENCODE:
|
elif type == constants.StreamType.ENCODE:
|
||||||
form = EncodeStreamForm(obj=stream)
|
form = EncodeStreamForm(obj=stream)
|
||||||
|
|
||||||
if request.method == 'POST' and form.validate_on_submit():
|
if request.method == 'POST' and form.validate_on_submit():
|
||||||
|
@ -248,7 +248,7 @@ class StreamView(FlaskView):
|
||||||
|
|
||||||
return render_template('stream/encode/edit.html', form=form,
|
return render_template('stream/encode/edit.html', form=form,
|
||||||
feedback_dir=stream.generate_feedback_dir())
|
feedback_dir=stream.generate_feedback_dir())
|
||||||
elif type == StreamType.TIMESHIFT_RECORDER:
|
elif type == constants.StreamType.TIMESHIFT_RECORDER:
|
||||||
form = TimeshiftRecorderStreamForm(obj=stream)
|
form = TimeshiftRecorderStreamForm(obj=stream)
|
||||||
|
|
||||||
if request.method == 'POST': # FIXME form.validate_on_submit()
|
if request.method == 'POST': # FIXME form.validate_on_submit()
|
||||||
|
@ -259,7 +259,7 @@ class StreamView(FlaskView):
|
||||||
return render_template('stream/timeshift_recorder/edit.html', form=form,
|
return render_template('stream/timeshift_recorder/edit.html', form=form,
|
||||||
feedback_dir=stream.generate_feedback_dir(),
|
feedback_dir=stream.generate_feedback_dir(),
|
||||||
timeshift_dir=stream.generate_timeshift_dir())
|
timeshift_dir=stream.generate_timeshift_dir())
|
||||||
elif type == StreamType.CATCHUP:
|
elif type == constants.StreamType.CATCHUP:
|
||||||
form = CatchupStreamForm(obj=stream)
|
form = CatchupStreamForm(obj=stream)
|
||||||
|
|
||||||
if request.method == 'POST': # FIXME form.validate_on_submit()
|
if request.method == 'POST': # FIXME form.validate_on_submit()
|
||||||
|
@ -270,7 +270,7 @@ class StreamView(FlaskView):
|
||||||
return render_template('stream/catchup/edit.html', form=form,
|
return render_template('stream/catchup/edit.html', form=form,
|
||||||
feedback_dir=stream.generate_feedback_dir(),
|
feedback_dir=stream.generate_feedback_dir(),
|
||||||
timeshift_dir=stream.generate_timeshift_dir())
|
timeshift_dir=stream.generate_timeshift_dir())
|
||||||
elif type == StreamType.TIMESHIFT_PLAYER:
|
elif type == constants.StreamType.TIMESHIFT_PLAYER:
|
||||||
form = TimeshiftPlayerStreamForm(obj=stream)
|
form = TimeshiftPlayerStreamForm(obj=stream)
|
||||||
|
|
||||||
if request.method == 'POST' and form.validate_on_submit():
|
if request.method == 'POST' and form.validate_on_submit():
|
||||||
|
@ -280,7 +280,7 @@ class StreamView(FlaskView):
|
||||||
|
|
||||||
return render_template('stream/timeshift_player/edit.html', form=form,
|
return render_template('stream/timeshift_player/edit.html', form=form,
|
||||||
feedback_dir=stream.generate_feedback_dir())
|
feedback_dir=stream.generate_feedback_dir())
|
||||||
elif type == StreamType.TEST_LIFE:
|
elif type == constants.StreamType.TEST_LIFE:
|
||||||
form = TestLifeStreamForm(obj=stream)
|
form = TestLifeStreamForm(obj=stream)
|
||||||
|
|
||||||
if request.method == 'POST': # FIXME form.validate_on_submit()
|
if request.method == 'POST': # FIXME form.validate_on_submit()
|
||||||
|
@ -290,7 +290,7 @@ class StreamView(FlaskView):
|
||||||
|
|
||||||
return render_template('stream/test_life/edit.html', form=form,
|
return render_template('stream/test_life/edit.html', form=form,
|
||||||
feedback_dir=stream.generate_feedback_dir())
|
feedback_dir=stream.generate_feedback_dir())
|
||||||
elif type == StreamType.VOD_RELAY:
|
elif type == constants.StreamType.VOD_RELAY:
|
||||||
form = VodRelayStreamForm(obj=stream)
|
form = VodRelayStreamForm(obj=stream)
|
||||||
|
|
||||||
if request.method == 'POST' and form.validate_on_submit():
|
if request.method == 'POST' and form.validate_on_submit():
|
||||||
|
@ -300,7 +300,7 @@ class StreamView(FlaskView):
|
||||||
|
|
||||||
return render_template('stream/vod_relay/edit.html', form=form,
|
return render_template('stream/vod_relay/edit.html', form=form,
|
||||||
feedback_dir=stream.generate_feedback_dir())
|
feedback_dir=stream.generate_feedback_dir())
|
||||||
elif type == StreamType.VOD_ENCODE:
|
elif type == constants.StreamType.VOD_ENCODE:
|
||||||
form = VodEncodeStreamForm(obj=stream)
|
form = VodEncodeStreamForm(obj=stream)
|
||||||
|
|
||||||
if request.method == 'POST' and form.validate_on_submit():
|
if request.method == 'POST' and form.validate_on_submit():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue