mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 20:52:20 +00:00
Lint code
This commit is contained in:
parent
c937c1624a
commit
b0eefa8590
13
.gitlab-ci.yml
Normal file
13
.gitlab-ci.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
stages:
|
||||||
|
- quality-assurance
|
||||||
|
|
||||||
|
linters:
|
||||||
|
image: python:3.7
|
||||||
|
stage: quality-assurance
|
||||||
|
before_script:
|
||||||
|
- pip install tox
|
||||||
|
script:
|
||||||
|
- tox -e linters
|
||||||
|
|
||||||
|
# Be nice to new contributors, but please use `tox` before commit
|
||||||
|
allow_failure: true
|
@ -1,20 +1,23 @@
|
|||||||
from flask import Flask, request, redirect, render_template
|
from flask import Flask, redirect, render_template, request
|
||||||
import ldap
|
import ldap
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.logger.setLevel(20) # log info
|
app.logger.setLevel(20) # log info
|
||||||
app.config.from_object('ghostream.default_settings')
|
app.config.from_object('ghostream.default_settings')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
"""Welcome page"""
|
"""Welcome page"""
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/<path:path>')
|
@app.route('/<path:path>')
|
||||||
def viewer(path):
|
def viewer(path):
|
||||||
"""Show stream that match this path"""
|
"""Show stream that match this path"""
|
||||||
return render_template('viewer.html', path=path)
|
return render_template('viewer.html', path=path)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/app/auth', methods=['POST'])
|
@app.route('/app/auth', methods=['POST'])
|
||||||
def auth():
|
def auth():
|
||||||
"""Authentication on stream start"""
|
"""Authentication on stream start"""
|
||||||
@ -38,6 +41,6 @@ def auth():
|
|||||||
app.logger.info("%s logged in successfully", name)
|
app.logger.info("%s logged in successfully", name)
|
||||||
# Remove "?pass=xxx" from RTMP URL
|
# Remove "?pass=xxx" from RTMP URL
|
||||||
return redirect(f"rtmp://127.0.0.1:1925/app/{name}", code=302)
|
return redirect(f"rtmp://127.0.0.1:1925/app/{name}", code=302)
|
||||||
except:
|
except Exception:
|
||||||
app.logger.warning("%s failed to log in", name)
|
app.logger.warning("%s failed to log in", name)
|
||||||
return 'Incorrect credentials', 401
|
return 'Incorrect credentials', 401
|
||||||
|
26
tox.ini
Normal file
26
tox.ini
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[tox]
|
||||||
|
envlist =
|
||||||
|
linters
|
||||||
|
skipsdist = True
|
||||||
|
|
||||||
|
[testenv:linters]
|
||||||
|
deps =
|
||||||
|
flake8
|
||||||
|
flake8-colors
|
||||||
|
flake8-import-order
|
||||||
|
flake8-typing-imports
|
||||||
|
pep8-naming
|
||||||
|
pyflakes
|
||||||
|
commands =
|
||||||
|
flake8 ghostream
|
||||||
|
|
||||||
|
[flake8]
|
||||||
|
exclude =
|
||||||
|
__pycache__,
|
||||||
|
*.pyc,
|
||||||
|
*.egg-info,
|
||||||
|
.cache,
|
||||||
|
.eggs
|
||||||
|
import-order-style = google
|
||||||
|
application-import-names = flake8
|
||||||
|
format = ${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
|
Loading…
Reference in New Issue
Block a user