wrapper for OpenERP exec_workflow Business Process Management engine
359133
def wkf_action(action, context={}, reload=true)
      self.class.object_service(:exec_workflow, self.class.openerp_model, action, self.id, context)
      reload_fields if reload
    end
1248170
function process(doc, cb) {
    freeze()
    assertParser('process', processor.Parser)
    assertCompiler('process', processor.Compiler)

    if (!cb) {
      return new Promise(executor)
    }

    executor(null, cb)

    function executor(resolve, reject) {
      var file = vfile(doc)

      pipeline.run(processor, {file: file}, done)

      function done(err) {
        if (err) {
          reject(err)
        } else if (resolve) {
          resolve(file)
        } else {
          cb(null, file)
        }
      }
    }
  }
1264862
def execute_processing_block(pb_id: str, log_level='DEBUG'):
    
    init_logger('sip', show_log_origin=True, propagate=False,
                log_level=log_level)
    LOG.info('+' * 40)
    LOG.info('+ Executing Processing block: %s!', pb_id)
    LOG.info('+' * 40)
    LOG.info('Processing Block Controller version: %s', __version__)
    LOG.info('Docker Swarm API version: %s', sip_swarm_api_version)
    LOG.info('Configuration database API version: %s', config_db_version)

    pb = ProcessingBlock(pb_id)

    LOG.info('Starting workflow %s %s', pb.workflow_id, pb.workflow_version)

    pb.set_status('running')
    docker = DockerSwarmClient()

    # Coping workflow stages to a dict
    workflow_stage_dict = {}
    for stage in pb.workflow_stages:
        workflow_stage_dict[stage.id] = deepcopy(stage.config)
        workflow_stage_dict[stage.id]['services'] = dict()

    # Loop until workflow stages are complete.
    while True:
        time.sleep(0.1)

        for workflow_stage in pb.workflow_stages:

            _start_workflow_stages(pb, pb_id, workflow_stage_dict,
                                   workflow_stage, docker)

            _update_workflow_stages(workflow_stage_dict[workflow_stage.id],
                                    workflow_stage, docker)

        if _abort_workflow(pb, workflow_stage_dict, docker):
            break

        if _workflow_complete(workflow_stage_dict):
            break

    pb_list = ProcessingBlockList()
    pb_list.set_complete(pb_id)
    pb.set_status('completed')
    LOG.info('-' * 40)
    LOG.info('- Destroying PBC for %s', pb_id)
    LOG.info('-' * 40)
    return pb.status
799857
def _run_workflow(data, workflow_file, work_dir):
    
    utils.remove_safe(os.path.join(work_dir, "workspace"))
    cmd = [utils.get_program_python("configureStrelkaGermlineWorkflow.py"),
           workflow_file, "-m", "local", "-j", dd.get_num_cores(data), "--quiet"]
    do.run(cmd, "Run Strelka2: %s" % dd.get_sample_name(data))
    utils.remove_safe(os.path.join(work_dir, "workspace"))
667838
function buildProcessTemplate(opts, callback) {
  var viewOpt = {
    app: opts.app,
    processName: opts.processName,
    directory: opts.directory,
    port: opts.port,
    command: opts.command,
    logRoot: opts.logRoot,
    num: opts.num,
    envVar: opts.envVar
  };

  renderTemplate(templateFilePath('process.conf', opts.templateOpt), viewOpt, function(err, renderedOutput) {
    if (err) {
      return callback(err.message);
    } else {
      return fs.writeFile(opts.writePath, renderedOutput, function(err) {
	if (err) {
	  return callback(err.message);
	} else {
	  return callback(null);
	}
      });
    }
  });
}
1162506
def create_CreateProcess(original_name):
    

    def new_CreateProcess(app_name, cmd_line, *args):
        try:
            import _subprocess
        except ImportError:
            import _winapi as _subprocess
        send_process_created_message()
        return getattr(_subprocess, original_name)(app_name, patch_arg_str_win(cmd_line), *args)

    return new_CreateProcess
1161994
def run(self):
        
        from zengine.lib.cache import WFSpecNames

        if self.manager.args.clear:
            self._clear_models()
            return

        if self.manager.args.wf_path:
            paths = self.get_wf_from_path(self.manager.args.wf_path)
        else:
            paths = self.get_workflows()

        self.count = 0

        self.do_with_submit(self.load_diagram, paths, threads=self.manager.args.threads)

        WFSpecNames().refresh()

        print("%s BPMN file loaded" % self.count)
637863
function runSuite() {
    execFile(flow, [ 'status', '--color', 'always' ], (err, stdout) => {
        process.stdout.write('\x1Bc')
        /* eslint-disable no-console */
        console.log(stdout)
        /* eslint-enable no-console */
    })
}
470730
def work(druid)
      LyberCore::Log.set_logfile($stdout) # let process manager(bluepill) handle logging
      LyberCore::Log.info "#{druid} processing"
      return if @check_queued_status && !item_queued?(druid)

      result = nil
      elapsed = Benchmark.realtime do
        result = perform druid # implemented in the mixed-in robot class
      end

      # this is the default note to pass back to workflow service, but it can be overriden by a robot that uses the Lybercore::Robot::ReturnState object to return a status
      note = Socket.gethostname

      # the final workflow state is determined by the return value of the perform step, if it is a ReturnState object,
      # we will use the defined status, otherwise default to completed
      # if a note is passed back, we will also use that instead of the default
      if result.class == LyberCore::Robot::ReturnState
        workflow_state = result.status
        note = result.note unless result.note.blank?
      else
        workflow_state = 'completed'
      end

      # update the workflow status from its current state to the state returned by perform (or 'completed' as the default)
      workflow_service.update_workflow_status(@repo, druid, @workflow_name, @step_name, workflow_state, elapsed: elapsed, note: note)
      LyberCore::Log.info "Finished #{druid} in #{sprintf('%0.4f', elapsed)}s"
    rescue StandardError => e
      Honeybadger.notify(e) if defined? Honeybadger
      begin
        LyberCore::Log.error e.message + "\n" + e.backtrace.join("\n")
        workflow_service.update_workflow_error_status(@repo, druid, @workflow_name, @step_name, e.message, error_text: Socket.gethostname)
      rescue StandardError => e2
        LyberCore::Log.error "Cannot set #{druid} to status='error'\n" + e2.message + "\n" + e2.backtrace.join("\n")
        raise e2 # send exception to Resque failed queue
      end
    end
1325952
def exec_python_rc(*args, **kwargs):
    
    cmdargs, kwargs = __wrap_python(args, kwargs)
    return exec_command_rc(*cmdargs, **kwargs)
1104664
def spawnPythonProcess(processProtocol, args=(), env={},
                       path=None, uid=None, gid=None, usePTY=0,
                       packages=()):
    
    return spawnProcess(processProtocol, sys.executable,
                        args, env, path, uid, gid, usePTY,
                        packages)
1312614
def run(self):
        
        builder = self.workflow.builder

        image = builder.image.to_str()
        # TODO: directly invoke go imagebuilder library in shared object via python module
        kwargs = dict(stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
        encoding_params = dict(encoding='utf-8', errors='replace')
        if not PY2:
            kwargs.update(encoding_params)

        allow_repo_dir_in_dockerignore(builder.df_dir)
        ib_process = subprocess.Popen(['imagebuilder', '-t', image, builder.df_dir], **kwargs)

        self.log.debug('imagebuilder build has begun; waiting for it to finish')
        output = []
        while True:
            poll = ib_process.poll()
            out = ib_process.stdout.readline()
            out = out.decode(**encoding_params) if PY2 else out
            if out:
                self.log.info('%s', out.rstrip())
                output.append(out)
            elif poll is not None:
                break

        if ib_process.returncode != 0:
            # in the case of an apparent failure, single out the last line to
            # include in the failure summary.
            err = output[-1] if output else "<imagebuilder had bad exit code but no output>"
            return BuildResult(
                logs=output,
                fail_reason="image build failed (rc={}): {}".format(ib_process.returncode, err),
            )

        image_id = builder.get_built_image_info()['Id']
        if ':' not in image_id:
            # Older versions of the daemon do not include the prefix
            image_id = 'sha256:{}'.format(image_id)

        # since we need no squash, export the image for local operations like squash would have
        self.log.info("fetching image %s from docker", image)
        output_path = os.path.join(self.workflow.source.workdir, EXPORTED_SQUASHED_IMAGE_NAME)
        try:
            # docker-py 1.x
            with open(output_path, "w") as image_file:
                image_file.write(self.tasker.d.get_image(image).data)
        except AttributeError:
            # docker-py 3.x
            with open(output_path, "wb") as image_file:
                for chunk in self.tasker.d.get_image(image):
                    image_file.write(chunk)

        img_metadata = get_exported_image_metadata(output_path, IMAGE_TYPE_DOCKER_ARCHIVE)
        self.workflow.exported_image_sequence.append(img_metadata)

        return BuildResult(logs=output, image_id=image_id, skip_layer_squash=True)
1229505
def update_wrapper(self, process_list):
        """"""
        # Set the number of running process
        self.set_count(len(process_list))
        # Call the children update method
        if self.should_update():
            return self.update(process_list)
        else:
            return self.result()
244642
def managed_process(process):
    """"""
    try:
        yield process
    finally:
        for stream in [process.stdout, process.stdin, process.stderr]:
            if stream:
                stream.close()
        process.wait()
520499
def call_workflow_event(instance, event, after=True):
    
    if not event.transition:
        return False

    portal_type = instance.portal_type
    wf_module = _load_wf_module('{}.events'.format(portal_type.lower()))
    if not wf_module:
        return False

    # Inspect if event_<transition_id> function exists in the module
    prefix = after and "after" or "before"
    func_name = "{}_{}".format(prefix, event.transition.id)
    func = getattr(wf_module, func_name, False)
    if not func:
        return False

    logger.info('WF event: {0}.events.{1}'
                .format(portal_type.lower(), func_name))
    func(instance)
    return True
394420
def workflow_update_stage_executable(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/updateStageExecutable' % object_id, input_params, always_retry=always_retry, **kwargs)
1093772
def execute(self, processProtocol, command, env={},
                path=None, uid=None, gid=None, usePTY=0, childFDs=None):
        
        raise NotImplementedError()