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__/
|
||||
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 -*-
|
||||
|
||||
# Copyright (c) 2019. Tobias Kurze
|
||||
import logging
|
||||
import ssl
|
||||
|
||||
from jinja2.exceptions import TemplateNotFound
|
||||
|
||||
from backend import app
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
import pkgutil
|
||||
|
||||
from flask_jwt_extended import jwt_required
|
||||
from flask_restplus import fields, Resource
|
||||
|
||||
@@ -12,6 +14,7 @@ from backend import db, app
|
||||
from backend.api import api_recorder
|
||||
from backend.models.recorder_model import Recorder, RecorderModel, RecorderCommand
|
||||
from backend.models.room_model import Room
|
||||
import backend.recorder_adapters as r_a
|
||||
|
||||
recorder_model = api_recorder.model('Recorder', {
|
||||
'id': fields.String(required=False, description='The recorder\'s identifier'),
|
||||
@@ -187,6 +190,18 @@ class RecorderModelList(Resource):
|
||||
@api_recorder.doc('recorders')
|
||||
@api_recorder.marshal_list_with(recorder_model_model)
|
||||
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
|
||||
:return: recorder models
|
||||
|
||||
@@ -72,10 +72,10 @@ class TelnetAdapter(ABC):
|
||||
elif self.tn is None:
|
||||
self.login()
|
||||
self.tn.write(cmd)
|
||||
out = tn.read_until_non_empty_line()
|
||||
out = self.tn.read_until_non_empty_line()
|
||||
res = 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)
|
||||
res += out
|
||||
return res
|
||||
|
||||
@@ -3,6 +3,8 @@ import sys
|
||||
from abc import ABC, abstractmethod
|
||||
from backend.recorder_adapters import telnetlib, TelnetAdapter
|
||||
|
||||
RECORDER_MODEL_NAME = "SMP 351 / 352"
|
||||
|
||||
# HOST = "localhost"
|
||||
# HOST = "129.13.51.102" # Audimax SMP 351
|
||||
# HOST = "129.13.51.106" # Tulla SMP 351
|
||||
@@ -728,41 +730,47 @@ class SMP(TelnetAdapter):
|
||||
return TelnetAdapter.get_response_str(self.tn.read_until_non_empty_line())
|
||||
|
||||
|
||||
smp = SMP(HOST, PW)
|
||||
print(smp)
|
||||
smp.login()
|
||||
print(smp.get_version(verbose_info=False))
|
||||
|
||||
print(smp.get_bootstrap_version())
|
||||
print(smp.get_part_number())
|
||||
print(smp.get_model_name())
|
||||
print(smp.get_model_description())
|
||||
def main():
|
||||
smp = SMP(HOST, PW)
|
||||
print(smp)
|
||||
smp.login()
|
||||
print(smp.get_version(verbose_info=False))
|
||||
|
||||
print(smp.get_system_memory_usage())
|
||||
print(smp.get_bootstrap_version())
|
||||
print(smp.get_part_number())
|
||||
print(smp.get_model_name())
|
||||
print(smp.get_model_description())
|
||||
|
||||
print(smp.get_file_transfer_config())
|
||||
print(smp.get_system_memory_usage())
|
||||
|
||||
# print(smp.get_unit_name())
|
||||
# print(smp.set_unit_name("mzsmp"))
|
||||
# print(smp.get_unit_name())
|
||||
# print(smp.reset_unit_name())
|
||||
print(smp.get_file_transfer_config())
|
||||
|
||||
print(smp.set_front_panel_lock(0))
|
||||
print(smp.get_front_panel_lock())
|
||||
# print(smp.get_unit_name())
|
||||
# print(smp.set_unit_name("mzsmp"))
|
||||
# print(smp.get_unit_name())
|
||||
# print(smp.reset_unit_name())
|
||||
|
||||
print(smp.get_input_name(1))
|
||||
print(smp.get_input_selction_per_channel())
|
||||
print(smp.get_recording_status())
|
||||
print("Preset Name: " + smp.get_user_preset_name(2))
|
||||
print(smp.get_user_presets(1))
|
||||
print(smp.get_input_presets())
|
||||
print(smp.get_layout_preset_name(2))
|
||||
print(smp.get_encoder_preset_name(1))
|
||||
print(smp.get_streaming_preset_name(2))
|
||||
print(smp.recall_encoder_preset(3, 1))
|
||||
print(smp.set_front_panel_lock(0))
|
||||
print(smp.get_front_panel_lock())
|
||||
|
||||
print(smp.get_input_name(1))
|
||||
print(smp.get_input_selction_per_channel())
|
||||
print(smp.get_recording_status())
|
||||
print("Preset Name: " + smp.get_user_preset_name(2))
|
||||
print(smp.get_user_presets(1))
|
||||
print(smp.get_input_presets())
|
||||
print(smp.get_layout_preset_name(2))
|
||||
print(smp.get_encoder_preset_name(1))
|
||||
print(smp.get_streaming_preset_name(2))
|
||||
print(smp.recall_encoder_preset(3, 1))
|
||||
|
||||
print(smp.is_muted(2))
|
||||
print(smp.mute_output(2))
|
||||
print(smp.is_muted(2))
|
||||
print(smp.unmute_output(2))
|
||||
print(smp.is_muted(2))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
print(smp.is_muted(2))
|
||||
print(smp.mute_output(2))
|
||||
print(smp.is_muted(2))
|
||||
print(smp.unmute_output(2))
|
||||
print(smp.is_muted(2))
|
||||
|
||||
@@ -12,6 +12,11 @@ from backend import app
|
||||
from backend.auth import oidc_auth
|
||||
|
||||
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, ""))
|
||||
|
||||
|
||||
@@ -43,7 +48,6 @@ def test_oidc():
|
||||
token_header=token_header)
|
||||
|
||||
|
||||
|
||||
def has_no_empty_params(rule):
|
||||
defaults = rule.defaults if rule.defaults is not None else ()
|
||||
arguments = rule.arguments if rule.arguments is not None else ()
|
||||
@@ -57,13 +61,14 @@ def site_map():
|
||||
# Filter out rules we can't navigate to in a browser
|
||||
# and rules that require parameters
|
||||
if has_no_empty_params(rule):
|
||||
#if "GET" in rule.methods and has_no_empty_params(rule):
|
||||
# if "GET" in rule.methods and has_no_empty_params(rule):
|
||||
url = url_for(rule.endpoint, **(rule.defaults or {}))
|
||||
links.append((url, rule.endpoint))
|
||||
# links is now a list of url, endpoint tuples
|
||||
#dump(links)
|
||||
# dump(links)
|
||||
return jsonify(links)
|
||||
|
||||
|
||||
@fe_bp.route('/', defaults={'path': ''})
|
||||
@fe_bp.route('/<path:path>')
|
||||
def catch_all(path):
|
||||
|
||||
Reference in New Issue
Block a user