def get_json_config(_file): """ _function_: `mast.datapower.web.get_json_config(_file)` return merged confiuration from `$MAST_HOME/etc/default/_file` and `$MAST_HOME/etc/local/_file` in json format this is used to allow `mast_web` plugins to have configuration within MAST's unified configuration system. Exposed at: `/config/_file` via GET Parameters: * `_file`: The name of the configuration file to parse and return. """ _file = _file if _file.endswith(".conf") else "{}.conf".format(_file) config = get_configs_dict()[_file] return flask.jsonify(config)
import cherrypy from cherrypy.wsgiserver.ssl_builtin import BuiltinSSLAdapter from cherrypy.wsgiserver import CherryPyWSGIServer import logging import random import string import flask import json import os import sys import getpass # TODO: map the configuration out better and # move to function. Also add defaults, so it can # run independant of any directory structure config = get_configs_dict()["server.conf"] static_dir = config["dirs"]["static"] template_dir = config["dirs"]["template"] if template_dir != os.path.abspath(template_dir): template_dir = os.path.join(os.environ["MAST_HOME"], template_dir) plugin_dir = config["dirs"]["plugins"] plugin_dir = os.path.join(os.environ["MAST_HOME"], plugin_dir) upload_dir = config["dirs"]["upload"] upload_dir = os.path.join(os.environ["MAST_HOME"], upload_dir) static_path = config["paths"]["static"] log_file = config["logging"]["file"] log_level = int(config["logging"]["level"]) debug = bool(config["server"]["debug"]) port = int(config["server"]["port"]) host = config["server"]["host"]
function_1("some_value") """ import logging from functools import wraps from mast.timestamp import Timestamp from logging.handlers import RotatingFileHandler from mast.config import get_configs_dict import getpass import os mast_home = os.environ["MAST_HOME"] __version__ = "{}-0".format(os.environ["MAST_VERSION"]) config = get_configs_dict() config = config["logging.conf"] level = int(config["logging"]["level"]) max_bytes = config["logging"]["max_bytes"] backup_count = int(config["logging"]["backup_count"]) delay = bool(config["logging"]["delay"]) propagate = bool(config["logging"]["propagate"]) filemode = "w" _format = "; ".join(( "'level'='%(levelname)s'", "'datetime'='%(asctime)s'", "'thread'='%(thread)d'", "'module'='%(module)s'", "'line'='%(lineno)d'",
""" import logging from functools import wraps from mast.timestamp import Timestamp from logging.handlers import RotatingFileHandler from mast.config import get_configs_dict import getpass import os import re from mast import __version__ mast_home = os.environ["MAST_HOME"] config = get_configs_dict() config = config["logging.conf"] level = int(config["logging"]["level"]) max_bytes = config["logging"]["max_bytes"] backup_count = int(config["logging"]["backup_count"]) delay = bool(config["logging"]["delay"]) propagate = bool(config["logging"]["propagate"]) filemode = "w" _format = "; ".join(( "'level'='%(levelname)s'", "'datetime'='%(asctime)s'", "'thread'='%(thread)d'", "'module'='%(module)s'", "'line'='%(lineno)d'",
import cherrypy from cheroot.ssl.builtin import BuiltinSSLAdapter from cheroot.wsgi import WSGIServer import logging import random import string import flask import json import os import sys import getpass # TODO: map the configuration out better and # move to function. Also add defaults, so it can # run independant of any directory structure config = get_configs_dict()["server.conf"] static_dir = config["dirs"]["static"] template_dir = config["dirs"]["template"] if template_dir != os.path.abspath(template_dir): template_dir = os.path.join(os.environ["MAST_HOME"], template_dir) plugin_dir = config["dirs"]["plugins"] plugin_dir = os.path.join(os.environ["MAST_HOME"], plugin_dir) upload_dir = config["dirs"]["upload"] upload_dir = os.path.join(os.environ["MAST_HOME"], upload_dir) static_path = config["paths"]["static"] log_file = config["logging"]["file"] log_level = int(config["logging"]["level"]) debug = bool(config["server"]["debug"]) port = int(config["server"]["port"]) host = config["server"]["host"]