using reflection to get models
This commit is contained in:
119
.gitignore
vendored
119
.gitignore
vendored
@@ -1 +1,120 @@
|
|||||||
|
app.db
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
.idea
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
node_modules/
|
||||||
|
frontend/node_modules/
|
||||||
|
backend/uploads/*
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
|
|
||||||
|
package-lock.json
|
||||||
|
|||||||
17
__main__.py
17
__main__.py
@@ -2,10 +2,27 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2019. Tobias Kurze
|
# Copyright (c) 2019. Tobias Kurze
|
||||||
|
import logging
|
||||||
|
import ssl
|
||||||
|
|
||||||
|
from jinja2.exceptions import TemplateNotFound
|
||||||
|
|
||||||
from backend import app
|
from backend import app
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
|
||||||
|
print(app.config.get("SERVER_NAME", None))
|
||||||
|
server_name = app.config.get("SERVER_NAME", None)
|
||||||
|
if server_name is not None and "ubkaps154.ubka.uni-karlsruhe.de" in server_name:
|
||||||
|
try:
|
||||||
|
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
|
||||||
|
context.load_cert_chain('cert.pem', 'key.pem')
|
||||||
|
app.run(debug=True, ssl_context=context, threaded=True)
|
||||||
|
except FileNotFoundError:
|
||||||
|
app.run(debug=True, threaded=True)
|
||||||
|
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ For example: listing of available auth providers or registration of users.
|
|||||||
|
|
||||||
Login through API does not start a new session, but instead returns JWT.
|
Login through API does not start a new session, but instead returns JWT.
|
||||||
"""
|
"""
|
||||||
|
import pkgutil
|
||||||
|
|
||||||
from flask_jwt_extended import jwt_required
|
from flask_jwt_extended import jwt_required
|
||||||
from flask_restplus import fields, Resource
|
from flask_restplus import fields, Resource
|
||||||
|
|
||||||
@@ -12,6 +14,7 @@ from backend import db, app
|
|||||||
from backend.api import api_recorder
|
from backend.api import api_recorder
|
||||||
from backend.models.recorder_model import Recorder, RecorderModel, RecorderCommand
|
from backend.models.recorder_model import Recorder, RecorderModel, RecorderCommand
|
||||||
from backend.models.room_model import Room
|
from backend.models.room_model import Room
|
||||||
|
import backend.recorder_adapters as r_a
|
||||||
|
|
||||||
recorder_model = api_recorder.model('Recorder', {
|
recorder_model = api_recorder.model('Recorder', {
|
||||||
'id': fields.String(required=False, description='The recorder\'s identifier'),
|
'id': fields.String(required=False, description='The recorder\'s identifier'),
|
||||||
@@ -187,6 +190,18 @@ class RecorderModelList(Resource):
|
|||||||
@api_recorder.doc('recorders')
|
@api_recorder.doc('recorders')
|
||||||
@api_recorder.marshal_list_with(recorder_model_model)
|
@api_recorder.marshal_list_with(recorder_model_model)
|
||||||
def get(self):
|
def get(self):
|
||||||
|
models = []
|
||||||
|
found_packages = list(pkgutil.iter_modules(r_a.__path__))
|
||||||
|
importer = found_packages[0][0]
|
||||||
|
for f_p in found_packages:
|
||||||
|
importer = f_p[0]
|
||||||
|
rec_model_module = importer.find_module(f_p[1]).load_module(f_p[1])
|
||||||
|
rec_model = {'id': f_p[1], 'name': f_p[1]}
|
||||||
|
if 'RECORDER_MODEL_NAME' in rec_model_module:
|
||||||
|
rec_model['name'] = rec_model_module.RECORDER_MODEL_NAME
|
||||||
|
models.append(rec_model)
|
||||||
|
print(models)
|
||||||
|
return models
|
||||||
"""
|
"""
|
||||||
List all recorder models
|
List all recorder models
|
||||||
:return: recorder models
|
:return: recorder models
|
||||||
|
|||||||
@@ -72,10 +72,10 @@ class TelnetAdapter(ABC):
|
|||||||
elif self.tn is None:
|
elif self.tn is None:
|
||||||
self.login()
|
self.login()
|
||||||
self.tn.write(cmd)
|
self.tn.write(cmd)
|
||||||
out = tn.read_until_non_empty_line()
|
out = self.tn.read_until_non_empty_line()
|
||||||
res = out
|
res = out
|
||||||
while out is not None and out != "":
|
while out is not None and out != "":
|
||||||
out = tn.read_until_non_empty_line()
|
out = self.tn.read_until_non_empty_line()
|
||||||
print(out)
|
print(out)
|
||||||
res += out
|
res += out
|
||||||
return res
|
return res
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import sys
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from backend.recorder_adapters import telnetlib, TelnetAdapter
|
from backend.recorder_adapters import telnetlib, TelnetAdapter
|
||||||
|
|
||||||
|
RECORDER_MODEL_NAME = "SMP 351 / 352"
|
||||||
|
|
||||||
# HOST = "localhost"
|
# HOST = "localhost"
|
||||||
# HOST = "129.13.51.102" # Audimax SMP 351
|
# HOST = "129.13.51.102" # Audimax SMP 351
|
||||||
# HOST = "129.13.51.106" # Tulla SMP 351
|
# HOST = "129.13.51.106" # Tulla SMP 351
|
||||||
@@ -728,6 +730,8 @@ class SMP(TelnetAdapter):
|
|||||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
smp = SMP(HOST, PW)
|
smp = SMP(HOST, PW)
|
||||||
print(smp)
|
print(smp)
|
||||||
smp.login()
|
smp.login()
|
||||||
@@ -766,3 +770,7 @@ print(smp.mute_output(2))
|
|||||||
print(smp.is_muted(2))
|
print(smp.is_muted(2))
|
||||||
print(smp.unmute_output(2))
|
print(smp.unmute_output(2))
|
||||||
print(smp.is_muted(2))
|
print(smp.is_muted(2))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ from backend import app
|
|||||||
from backend.auth import oidc_auth
|
from backend.auth import oidc_auth
|
||||||
|
|
||||||
fe_path = os.path.abspath(os.path.join(app.root_path, os.pardir, "frontend", "dist"))
|
fe_path = os.path.abspath(os.path.join(app.root_path, os.pardir, "frontend", "dist"))
|
||||||
|
if not os.path.exists(fe_path) or not os.path.exists(os.path.join(fe_path, "index.html")):
|
||||||
|
app.logger.critical(
|
||||||
|
"Frontend path and/or index.html does not exist! Please build frontend before continuing! "
|
||||||
|
"You might want to go to ../frontend and continue from there.")
|
||||||
|
exit()
|
||||||
fe_bp = Blueprint('frontend', __name__, url_prefix='/', template_folder=os.path.join(fe_path, ""))
|
fe_bp = Blueprint('frontend', __name__, url_prefix='/', template_folder=os.path.join(fe_path, ""))
|
||||||
|
|
||||||
|
|
||||||
@@ -43,7 +48,6 @@ def test_oidc():
|
|||||||
token_header=token_header)
|
token_header=token_header)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def has_no_empty_params(rule):
|
def has_no_empty_params(rule):
|
||||||
defaults = rule.defaults if rule.defaults is not None else ()
|
defaults = rule.defaults if rule.defaults is not None else ()
|
||||||
arguments = rule.arguments if rule.arguments is not None else ()
|
arguments = rule.arguments if rule.arguments is not None else ()
|
||||||
@@ -64,6 +68,7 @@ def site_map():
|
|||||||
# dump(links)
|
# dump(links)
|
||||||
return jsonify(links)
|
return jsonify(links)
|
||||||
|
|
||||||
|
|
||||||
@fe_bp.route('/', defaults={'path': ''})
|
@fe_bp.route('/', defaults={'path': ''})
|
||||||
@fe_bp.route('/<path:path>')
|
@fe_bp.route('/<path:path>')
|
||||||
def catch_all(path):
|
def catch_all(path):
|
||||||
|
|||||||
Reference in New Issue
Block a user