cleanup and log SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR

This commit is contained in:
burnettk 2023-08-31 21:01:11 -04:00
parent b60b620f16
commit 0667436c15
4 changed files with 7 additions and 19 deletions

View File

@ -1,11 +1,11 @@
"""Deletes all permissions and then re-imports from yaml file.""" """Deletes all permissions and then re-imports from yaml file."""
from spiffworkflow_backend import get_hacked_up_app_for_script from spiffworkflow_backend import create_app
from spiffworkflow_backend.services.authorization_service import AuthorizationService from spiffworkflow_backend.services.authorization_service import AuthorizationService
def main() -> None: def main() -> None:
"""Main.""" """Main."""
app = get_hacked_up_app_for_script() app = create_app()
with app.app_context(): with app.app_context():
AuthorizationService.delete_all_permissions() AuthorizationService.delete_all_permissions()
AuthorizationService.import_permissions_from_yaml_file() AuthorizationService.import_permissions_from_yaml_file()

View File

@ -1,7 +1,7 @@
"""Grabs tickets from csv and makes process instances.""" """Grabs tickets from csv and makes process instances."""
import csv import csv
from spiffworkflow_backend import get_hacked_up_app_for_script from spiffworkflow_backend import create_app
from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.db import db
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
from spiffworkflow_backend.models.user import UserModel from spiffworkflow_backend.models.user import UserModel
@ -11,7 +11,7 @@ from spiffworkflow_backend.services.process_instance_service import ProcessInsta
def main(): def main():
"""Main.""" """Main."""
app = get_hacked_up_app_for_script() app = create_app()
with app.app_context(): with app.app_context():
process_model_identifier_ticket = "ticket" process_model_identifier_ticket = "ticket"
db.session.query(ProcessInstanceModel).filter( db.session.query(ProcessInstanceModel).filter(

View File

@ -205,21 +205,6 @@ def _setup_prometheus_metrics(app: flask.app.Flask, connexion_app: connexion.app
metrics.info("version_info", "Application Version Info", **version_info_data_normalized) metrics.info("version_info", "Application Version Info", **version_info_data_normalized)
def get_hacked_up_app_for_script() -> flask.app.Flask:
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development"
flask_env_key = "FLASK_SESSION_SECRET_KEY"
os.environ[flask_env_key] = "whatevs"
if "SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR" not in os.environ:
home = os.environ["HOME"]
full_process_model_path = f"{home}/projects/github/sartography/sample-process-models"
if os.path.isdir(full_process_model_path):
os.environ["SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR"] = full_process_model_path
else:
raise Exception(f"Could not find {full_process_model_path}")
app = create_app()
return app
def traces_sampler(sampling_context: Any) -> Any: def traces_sampler(sampling_context: Any) -> Any:
# always inherit # always inherit
if sampling_context["parent_sampled"] is not None: if sampling_context["parent_sampled"] is not None:

View File

@ -184,6 +184,9 @@ def setup_config(app: Flask) -> None:
setup_database_configs(app) setup_database_configs(app)
setup_logger(app) setup_logger(app)
app.logger.debug(
f"SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR: {app.config['SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR']}"
)
if app.config["SPIFFWORKFLOW_BACKEND_DEFAULT_USER_GROUP"] == "": if app.config["SPIFFWORKFLOW_BACKEND_DEFAULT_USER_GROUP"] == "":
app.config["SPIFFWORKFLOW_BACKEND_DEFAULT_USER_GROUP"] = None app.config["SPIFFWORKFLOW_BACKEND_DEFAULT_USER_GROUP"] = None