2023-01-23 21:45:07 +00:00
|
|
|
"""Get the bpmn process json for a given process instance id and store it in /tmp."""
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from spiffworkflow_backend import create_app
|
|
|
|
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
|
|
|
from spiffworkflow_backend.models.user import UserModel
|
|
|
|
from spiffworkflow_backend.services.secret_service import SecretService
|
|
|
|
|
|
|
|
|
|
|
|
def main(env_file: str):
|
|
|
|
"""Main."""
|
2023-02-07 20:02:47 +00:00
|
|
|
os.environ["SPIFFWORKFLOW_BACKEND_ENV"] = "local_development"
|
2023-02-15 22:07:12 +00:00
|
|
|
if os.environ.get("SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR") is None:
|
|
|
|
os.environ["SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR"] = "hey"
|
2023-01-23 21:45:07 +00:00
|
|
|
flask_env_key = "FLASK_SESSION_SECRET_KEY"
|
|
|
|
os.environ[flask_env_key] = "whatevs"
|
|
|
|
app = create_app()
|
|
|
|
with app.app_context():
|
|
|
|
contents = None
|
|
|
|
with open(env_file, 'r') as f:
|
|
|
|
contents = f.readlines()
|
|
|
|
for line in contents:
|
|
|
|
key, value_raw = line.split('=')
|
2023-01-23 22:18:47 +00:00
|
|
|
value = value_raw.replace('"', '').rstrip()
|
2023-01-23 21:45:07 +00:00
|
|
|
SecretService().add_secret(key, value, UserModel.query.first().id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) < 2:
|
|
|
|
raise Exception("env file must be specified")
|
|
|
|
|
|
|
|
main(sys.argv[1])
|