fix lint, update script, extend columns

This commit is contained in:
burnettk 2022-09-16 18:22:10 -04:00
parent aed0118861
commit 46a0c02e96
5 changed files with 50 additions and 35 deletions

View File

@ -1,12 +1,12 @@
"""Grabs tickets from csv and makes process instances."""
import os
from lxml.etree import Element as EtreeElement
from spiffworkflow_backend import create_app
from spiffworkflow_backend.services.process_model_service import ProcessModelService
from spiffworkflow_backend.services.spec_file_service import SpecFileService
from lxml.etree import Element as EtreeElement
def main():
"""Main."""
@ -14,42 +14,56 @@ def main():
flask_env_key = "FLASK_SESSION_SECRET_KEY"
os.environ[flask_env_key] = "whatevs"
home = os.environ["HOME"]
os.environ["BPMN_SPEC_ABSOLUTE_DIR"] = f"{home}/projects/github/sartography/sample-process-models"
os.environ[
"BPMN_SPEC_ABSOLUTE_DIR"
] = f"{home}/projects/github/sartography/sample-process-models"
app = create_app()
with app.app_context():
no_primary = []
process_models = ProcessModelService().get_process_models()
for process_model in process_models:
if process_model.primary_file_name:
files = SpecFileService.get_files(process_model, extension_filter="bpmn")
files = SpecFileService.get_files(
process_model, extension_filter="bpmn"
)
if len(files) == 1:
# print(f"primary_file_name: {process_model.primary_file_name}")
bpmn_xml_file_contents = SpecFileService.get_data(
process_model, process_model.primary_file_name
)
# bpmn_etree_element: EtreeElement = (
# SpecFileService.get_etree_element_from_binary_data(
# bpmn_xml_file_contents, process_model.primary_file_name
# )
# )
# try:
# attributes_to_update = {
# "primary_process_id": (
# SpecFileService.get_bpmn_process_identifier(
# bpmn_etree_element
# )
# ),
# }
# ProcessModelService().update_spec(
# process_model, attributes_to_update
# )
SpecFileService.update_file(process_model, process_model.primary_file_name, bpmn_xml_file_contents)
# except Exception:
# print(process_model.id)
bpmn_etree_element: EtreeElement = (
SpecFileService.get_etree_element_from_binary_data(
bpmn_xml_file_contents, process_model.primary_file_name
)
)
try:
new_bpmn_process_identifier = (
SpecFileService.get_bpmn_process_identifier(
bpmn_etree_element
)
)
if (
process_model.primary_process_id
!= new_bpmn_process_identifier
):
print(
"primary_process_id: ", process_model.primary_process_id
)
# attributes_to_update = {
# "primary_process_id": new_bpmn_process_identifier
# }
# ProcessModelService().update_spec(
# process_model, attributes_to_update
# )
# SpecFileService.update_file(process_model, process_model.primary_file_name, bpmn_xml_file_contents)
# except Exception as exception:
except Exception:
print(f"BAD ONE: {process_model.id}")
# raise exception
else:
no_primary.append(process_model)
for bpmn in no_primary:
print(bpmn)
# for bpmn in no_primary:
# print(bpmn)
if __name__ == "__main__":

View File

@ -1,8 +1,8 @@
"""empty message
Revision ID: 097f52a3ec5d
Revision ID: 6d3ffcc6849e
Revises:
Create Date: 2022-09-16 10:44:23.258357
Create Date: 2022-09-16 18:20:43.082949
"""
from alembic import op
@ -10,7 +10,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '097f52a3ec5d'
revision = '6d3ffcc6849e'
down_revision = None
branch_labels = None
depends_on = None
@ -208,11 +208,11 @@ def upgrade():
op.create_table('spiff_logging',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('process_instance_id', sa.Integer(), nullable=False),
sa.Column('bpmn_process_identifier', sa.String(length=50), nullable=False),
sa.Column('bpmn_task_identifier', sa.String(length=50), nullable=False),
sa.Column('bpmn_process_identifier', sa.String(length=255), nullable=False),
sa.Column('bpmn_task_identifier', sa.String(length=255), nullable=False),
sa.Column('spiff_task_guid', sa.String(length=50), nullable=False),
sa.Column('timestamp', sa.DECIMAL(precision=17, scale=6), nullable=False),
sa.Column('message', sa.String(length=50), nullable=True),
sa.Column('message', sa.String(length=255), nullable=True),
sa.Column('current_user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['current_user_id'], ['user.id'], ),
sa.ForeignKeyConstraint(['process_instance_id'], ['process_instance.id'], ),

View File

@ -17,9 +17,9 @@ class SpiffLoggingModel(SpiffworkflowBaseDBModel):
__tablename__ = "spiff_logging"
id: int = db.Column(db.Integer, primary_key=True)
process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False) # type: ignore
bpmn_process_identifier: str = db.Column(db.String(50), nullable=False)
bpmn_task_identifier: str = db.Column(db.String(50), nullable=False)
bpmn_process_identifier: str = db.Column(db.String(255), nullable=False)
bpmn_task_identifier: str = db.Column(db.String(255), nullable=False)
spiff_task_guid: str = db.Column(db.String(50), nullable=False)
timestamp: float = db.Column(db.DECIMAL(17, 6), nullable=False)
message: Optional[str] = db.Column(db.String(50), nullable=True)
message: Optional[str] = db.Column(db.String(255), nullable=True)
current_user_id: int = db.Column(ForeignKey(UserModel.id), nullable=True)

View File

@ -654,7 +654,7 @@ def process_instance_report_delete(
def service_tasks_show() -> flask.wrappers.Response:
"""service_tasks_show."""
"""Service_tasks_show."""
available_connectors = ServiceTaskService.available_connectors()
print(available_connectors)

View File

@ -22,6 +22,7 @@ class ServiceTaskDelegate:
"""Calls a connector via the configured proxy."""
def normalize_value(v: Any) -> Any:
"""Normalize_value."""
value = v["value"]
secret_prefix = "secret:" # noqa: S105
if value.startswith(secret_prefix):