def get_workflow_permissions(permission_list=None): # [('code_name', 'name', 'description'),...] permissions = permission_list or [] from zengine.config import settings from zengine.engine import ZEngine, Current, log engine = ZEngine() for package_dir in settings.WORKFLOW_PACKAGES_PATHS: for bpmn_diagram_path in glob.glob(package_dir + "/*.bpmn"): wf_name = os.path.splitext(os.path.basename(bpmn_diagram_path))[0] permissions.append((wf_name, wf_name, "")) engine.current = Current(workflow_name=wf_name) try: workflow = engine.load_or_create_workflow() except: log.exception("Workflow cannot be created.") # print(wf_name) # pprint(workflow.spec.task_specs) for name, task_spec in workflow.spec.task_specs.items(): if any(no_perm_task in name for no_perm_task in NO_PERM_TASKS): continue permissions.append(("%s.%s" % (wf_name, name), "%s %s of %s" % (name, task_spec.__class__.__name__, wf_name), "")) return permissions
def _get_workflows(): from zengine.engine import ZEngine, WFCurrent from zengine.models import BPMNWorkflow workflows = [] for wf in BPMNWorkflow.objects.all(): engine = ZEngine() engine.current = WFCurrent(workflow_name=wf.name) workflows.append(engine.load_or_create_workflow()) return workflows
def get_workflows(): from zengine.config import settings from zengine.engine import ZEngine, WFCurrent workflows = [] for package_dir in settings.WORKFLOW_PACKAGES_PATHS: for bpmn_diagram_path in glob.glob(package_dir + "/*.bpmn"): wf_name = os.path.splitext(os.path.basename(bpmn_diagram_path))[0] engine = ZEngine() engine.current = WFCurrent(workflow_name=wf_name) workflows.append(engine.load_or_create_workflow()) return workflows
class Connector(object): """ this is object will be used to catch all requests from falcon and map them to workflow engine. a request to domain.com/show_dashboard/ will invoke a workflow named show_dashboard with the payload json data """ def __init__(self): self.engine = ZEngine() def on_get(self, req, resp, wf_name): self.on_post(req, resp, wf_name) def on_post(self, req, resp, wf_name): self.engine.start_engine(request=req, response=resp, workflow_name=wf_name) self.engine.run()
class Connector(object): """ this is a callable object to catch all requests and map them to workflow engine. domain.com/show_dashboard/blah/blah/x=2&y=1 will invoke a workflow named show_dashboard """ # def __init__(self): # self.logger = logging.getLogger('dispatch.' + __name__) def __init__(self): self.engine = ZEngine() def on_get(self, req, resp, wf_name): self.on_post(req, resp, wf_name) def on_post(self, req, resp, wf_name): self.engine.start_engine(request=req, response=resp, workflow_name=wf_name) self.engine.run()
from pyoko.lib.utils import get_object_from_path from zengine.client_queue import ClientQueue, BLOCKING_MQ_PARAMS from zengine.engine import ZEngine from zengine.current import Current from zengine.lib.cache import Session, KeepAlive from zengine.lib.exceptions import HTTPError, SecurityInfringementAttempt from zengine.lib.decorators import VIEW_METHODS, JOB_METHODS, runtime_importer from zengine.log import log import sys runtime_importer() sys._zops_wf_state_log = '' wf_engine = ZEngine() LOGIN_REQUIRED_MESSAGE = {"cmd": "error", "error": "Login required", "code": 401} class Worker(object): """ Workflow runner worker object """ INPUT_QUEUE_NAME = 'in_queue' INPUT_EXCHANGE = 'input_exc' def __init__(self): self.connect() signal.signal(signal.SIGTERM, self.exit) log.info("Worker starting")
def __init__(self): self.engine = ZEngine()