INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Set the input or output mode for a specified pin. Mode should be either DIR_IN or DIR_OUT.
def setup(self,pin,mode): """Set the input or output mode for a specified pin. Mode should be either DIR_IN or DIR_OUT. """ self.mraa_gpio.Gpio.dir(self.mraa_gpio.Gpio(pin),self._dir_mapping[mode])
Set the specified pin the provided high/ low value. Value should be either 1 ( ON or HIGH ) or 0 ( OFF or LOW ) or a boolean.
def output(self,pin,value): """Set the specified pin the provided high/low value. Value should be either 1 (ON or HIGH), or 0 (OFF or LOW) or a boolean. """ self.mraa_gpio.Gpio.write(self.mraa_gpio.Gpio(pin), value)
Read the specified pin and return HIGH/ true if the pin is pulled high or LOW/ false if pulled low.
def input(self,pin): """Read the specified pin and return HIGH/true if the pin is pulled high, or LOW/false if pulled low. """ return self.mraa_gpio.Gpio.read(self.mraa_gpio.Gpio(pin))
Enable edge detection events for a particular GPIO channel. Pin should be type IN. Edge must be RISING FALLING or BOTH. Callback is a function for the event. Bouncetime is switch bounce timeout in ms for callback
def add_event_detect(self, pin, edge, callback=None, bouncetime=-1): """Enable edge detection events for a particular GPIO channel. Pin should be type IN. Edge must be RISING, FALLING or BOTH. Callback is a function for the event. Bouncetime is switch bounce timeout in ms for callb...
Remove edge detection for a particular GPIO channel. Pin should be type IN.
def remove_event_detect(self, pin): """Remove edge detection for a particular GPIO channel. Pin should be type IN. """ self.mraa_gpio.Gpio.isrExit(self.mraa_gpio.Gpio(pin))
Wait for an edge. Pin should be type IN. Edge must be RISING FALLING or BOTH.
def wait_for_edge(self, pin, edge): """Wait for an edge. Pin should be type IN. Edge must be RISING, FALLING or BOTH. """ self.bbio_gpio.wait_for_edge(self.mraa_gpio.Gpio(pin), self._edge_mapping[edge])
Returns a generator of Path s
def all_info_files(self) : 'Returns a generator of "Path"s' try : for info_file in list_files_in_dir(self.info_dir): if not os.path.basename(info_file).endswith('.trashinfo') : self.on_non_trashinfo_found() else : yield ...
Return a textual description of the file pointed by this path. Options: - symbolic link - directory -. directory -.. directory - regular file - regular empty file - non existent - entry
def describe(path): """ Return a textual description of the file pointed by this path. Options: - "symbolic link" - "directory" - "'.' directory" - "'..' directory" - "regular file" - "regular empty file" - "non existent" - "entry" """ if os.path.islink(path):...
Trash a file in the appropriate trash directory. If the file belong to the same volume of the trash home directory it will be trashed in the home trash directory. Otherwise it will be trashed in one of the relevant volume trash directories.
def trash(self, file) : """ Trash a file in the appropriate trash directory. If the file belong to the same volume of the trash home directory it will be trashed in the home trash directory. Otherwise it will be trashed in one of the relevant volume trash directories. ...
Create a. trashinfo file in the $trash/ info directory. returns the created TrashInfoFile.
def persist_trash_info(self, basename, content, logger): """ Create a .trashinfo file in the $trash/info directory. returns the created TrashInfoFile. """ self.ensure_dir(self.info_dir, 0o700) # write trash info index = 0 while True : if inde...
Returns the ProcessParser for the given process ID or name. It matches by name first.
def get_process_parser(self, process_id_or_name): """ Returns the ProcessParser for the given process ID or name. It matches by name first. """ if process_id_or_name in self.process_parsers_by_name: return self.process_parsers_by_name[process_id_or_name] else:...
Add all filenames in the given list to the parser s set.
def add_bpmn_files(self, filenames): """ Add all filenames in the given list to the parser's set. """ for filename in filenames: f = open(filename, 'r') try: self.add_bpmn_xml(ET.parse(f), filename=filename) finally: f.c...
Add the given lxml representation of the BPMN file to the parser s set.
def add_bpmn_xml(self, bpmn, svg=None, filename=None): """ Add the given lxml representation of the BPMN file to the parser's set. :param svg: Optionally, provide the text data for the SVG of the BPMN file :param filename: Optionally, provide the source filename. """ ...
Assert that there is exactly one node in the give list and return it.
def one(nodes, or_none=False): """ Assert that there is exactly one node in the give list, and return it. """ if not nodes and or_none: return None assert len( nodes) == 1, 'Expected 1 result. Received %d results.' % (len(nodes)) return nodes[0]
Returns an XPathEvaluator with namespace prefixes bpmn for http:// www. omg. org/ spec/ BPMN/ 20100524/ MODEL and additional specified ones
def xpath_eval(node, extra_ns=None): """ Returns an XPathEvaluator, with namespace prefixes 'bpmn' for http://www.omg.org/spec/BPMN/20100524/MODEL, and additional specified ones """ namespaces = {'bpmn': BPMN_MODEL_NS} if extra_ns: namespaces.update(extra_ns) return lambda path: node...
Serializer for: meth: SpiffWorkflow. operators. Attrib.
def serialize_attrib(self, op): """ Serializer for :meth:`SpiffWorkflow.operators.Attrib`. Example:: <attribute>foobar</attribute> """ elem = etree.Element('attribute') elem.text = op.name return elem
Serializer for: meth: SpiffWorkflow. operators. PathAttrib.
def serialize_pathattrib(self, op): """ Serializer for :meth:`SpiffWorkflow.operators.PathAttrib`. Example:: <path>foobar</path> """ elem = etree.Element('path') elem.text = op.path return elem
Serializer for: meth: SpiffWorkflow. operators. Assign.
def serialize_assign(self, op): """ Serializer for :meth:`SpiffWorkflow.operators.Assign`. Example:: <assign> <name>foobar</name> <value>doodle</value> </assign> """ elem = etree.Element('assign') self.serialize_va...
Serializes str Attrib or PathAttrib objects.
def serialize_value(self, parent_elem, value): """ Serializes str, Attrib, or PathAttrib objects. Example:: <attribute>foobar</attribute> """ if isinstance(value, (str, int)) or type(value).__name__ == 'str': parent_elem.text = str(value) elif va...
Serializes a dictionary of key/ value pairs where the values are either strings or Attrib or PathAttrib objects.
def serialize_value_map(self, map_elem, thedict): """ Serializes a dictionary of key/value pairs, where the values are either strings, or Attrib, or PathAttrib objects. Example:: <variable> <name>foo</name> <value>text</value> </v...
Serializes a list where the values are objects of type str Attrib or PathAttrib.
def serialize_value_list(self, list_elem, thelist): """ Serializes a list, where the values are objects of type str, Attrib, or PathAttrib. Example:: <value>text</value> <value><attribute>foobar</attribute></value> <value><path>foobar</path></value> ...
Serializer for: meth: SpiffWorkflow. operators. Equal.
def serialize_operator_equal(self, op): """ Serializer for :meth:`SpiffWorkflow.operators.Equal`. Example:: <equals> <value>text</value> <value><attribute>foobar</attribute></value> <value><path>foobar</path></value> </equ...
Serializer for: meth: SpiffWorkflow. operators. NotEqual.
def serialize_operator_not_equal(self, op): """ Serializer for :meth:`SpiffWorkflow.operators.NotEqual`. Example:: <not-equals> <value>text</value> <value><attribute>foobar</attribute></value> <value><path>foobar</path></value> ...
Serializer for: meth: SpiffWorkflow. operators. NotEqual.
def serialize_operator_greater_than(self, op): """ Serializer for :meth:`SpiffWorkflow.operators.NotEqual`. Example:: <greater-than> <value>text</value> <value><attribute>foobar</attribute></value> </greater-than> """ elem...
Serializer for: meth: SpiffWorkflow. operators. NotEqual.
def serialize_operator_less_than(self, op): """ Serializer for :meth:`SpiffWorkflow.operators.NotEqual`. Example:: <less-than> <value>text</value> <value><attribute>foobar</attribute></value> </less-than> """ elem = etree....
Serializer for: meth: SpiffWorkflow. operators. NotEqual.
def serialize_operator_match(self, op): """ Serializer for :meth:`SpiffWorkflow.operators.NotEqual`. Example:: <matches> <value>text</value> <value><attribute>foobar</attribute></value> </matches> """ elem = etree.Element(...
Serializes common attributes of: meth: SpiffWorkflow. specs. TaskSpec.
def serialize_task_spec(self, spec, elem): """ Serializes common attributes of :meth:`SpiffWorkflow.specs.TaskSpec`. """ if spec.id is not None: SubElement(elem, 'id').text = str(spec.id) SubElement(elem, 'name').text = spec.name if spec.description: ...
Serializer for: meth: SpiffWorkflow. specs. AcquireMutex.
def serialize_acquire_mutex(self, spec): """ Serializer for :meth:`SpiffWorkflow.specs.AcquireMutex`. """ elem = etree.Element('acquire-mutex') self.serialize_task_spec(spec, elem) SubElement(elem, 'mutex').text = spec.mutex return elem
Parse the event definition node and return an instance of Event
def get_event_definition(self): """ Parse the event definition node, and return an instance of Event """ messageEventDefinition = first( self.xpath('.//bpmn:messageEventDefinition')) if messageEventDefinition is not None: return self.get_message_event_defi...
Parse the messageEventDefinition node and return an instance of MessageEventDefinition
def get_message_event_definition(self, messageEventDefinition): """ Parse the messageEventDefinition node and return an instance of MessageEventDefinition """ messageRef = first(self.xpath('.//bpmn:messageRef')) message = messageRef.get( 'name') if messageRef ...
Parse the timerEventDefinition node and return an instance of TimerEventDefinition
def get_timer_event_definition(self, timerEventDefinition): """ Parse the timerEventDefinition node and return an instance of TimerEventDefinition This currently only supports the timeDate node for specifying an expiry time for the timer. """ timeDate = first(sel...
Returns a set of the distinct lane names used in the process ( including called activities )
def get_all_lanes(self): """ Returns a set of the distinct lane names used in the process (including called activities) """ done = set() lanes = set() def recursive_find(task_spec): if task_spec in done: return done.add(t...
Get the specs for all processes ( including called ones ) in depth first order.
def get_specs_depth_first(self): """ Get the specs for all processes (including called ones), in depth first order. """ done = set() specs = [self] def recursive_find(task_spec): if task_spec in done: return done.add(task...
Returns an etree HTML node with a document describing the process. This is only supported if the editor provided an SVG representation.
def to_html_string(self): """ Returns an etree HTML node with a document describing the process. This is only supported if the editor provided an SVG representation. """ html = ET.Element('html') head = ET.SubElement(html, 'head') title = ET.SubElement(head, 'titl...
Connects the event with the given callback. When the signal is emitted the callback is invoked.
def connect(self, callback, *args, **kwargs): """ Connects the event with the given callback. When the signal is emitted, the callback is invoked. .. note:: The signal handler is stored with a hard reference, so you need to make sure to call :class:`disconnect()...
Like: class: connect () but uses a weak reference instead of a normal reference. The signal is automatically disconnected as soon as the handler is garbage collected.
def listen(self, callback, *args, **kwargs): """ Like :class:`connect()`, but uses a weak reference instead of a normal reference. The signal is automatically disconnected as soon as the handler is garbage collected. .. note:: Storing signal handlers as weak...
Returns the number of connected subscribers.
def n_subscribers(self): """ Returns the number of connected subscribers. :rtype: int :returns: The number of subscribers. """ hard = self.hard_subscribers and len(self.hard_subscribers) or 0 weak = self.weak_subscribers and len(self.weak_subscribers) or 0 ...
Returns True if the event is connected to the given function.
def is_connected(self, callback): """ Returns True if the event is connected to the given function. :type callback: object :param callback: The callback function. :rtype: bool :returns: Whether the signal is connected to the given function. """ index = ...
Emits the signal passing the given arguments to the callbacks. If one of the callbacks returns a value other than None no further callbacks are invoked and the return value of the callback is returned to the caller of emit ().
def emit(self, *args, **kwargs): """ Emits the signal, passing the given arguments to the callbacks. If one of the callbacks returns a value other than None, no further callbacks are invoked and the return value of the callback is returned to the caller of emit(). :type ...
Called by the weak reference when its target dies. In other words we can assert that self. weak_subscribers is not None at this time.
def _try_disconnect(self, ref): """ Called by the weak reference when its target dies. In other words, we can assert that self.weak_subscribers is not None at this time. """ with self.lock: weak = [s[0] for s in self.weak_subscribers] try: ...
Disconnects the signal from the given function.
def disconnect(self, callback): """ Disconnects the signal from the given function. :type callback: object :param callback: The callback function. """ if self.weak_subscribers is not None: with self.lock: index = self._weakly_connected_index(...
: param s_state: a byte - string with the contents of the packaged workflow archive or a file - like object.
def deserialize_workflow_spec(self, s_state, filename=None): """ :param s_state: a byte-string with the contents of the packaged workflow archive, or a file-like object. :param filename: the name of the package file. """ if isinstance(s_state, (str, bytes)): ...
Parse this node and all children returning the connected task spec.
def parse_node(self): """ Parse this node, and all children, returning the connected task spec. """ try: self.task = self.create_task() self.task.documentation = self.parser._parse_documentation( self.node, xpath=self.xpath, task_parser=self) ...
Create an instance of the task appropriately. A subclass can override this method to get extra information from the node.
def create_task(self): """ Create an instance of the task appropriately. A subclass can override this method to get extra information from the node. """ return self.spec_class(self.spec, self.get_task_spec_name(), lane=self.get_lane(), ...
Connects this task to the indicating outgoing task with the details in the sequence flow. A subclass can override this method to get extra information from the node.
def connect_outgoing(self, outgoing_task, outgoing_task_node, sequence_flow_node, is_default): """ Connects this task to the indicating outgoing task, with the details in the sequence flow. A subclass can override this method to get extra information from the nod...
Connect this task spec to the indicated child.
def connect_outgoing(self, taskspec, sequence_flow_id, sequence_flow_name, documentation): """ Connect this task spec to the indicated child. :param sequence_flow_id: The ID of the connecting sequenceFlow node. :param sequence_flow_name: The name of the connect...
Connect this task spec to the indicated child if the condition evaluates to true. This should only be called if the task has a connect_if method ( e. g. ExclusiveGateway ).
def connect_outgoing_if(self, condition, taskspec, sequence_flow_id, sequence_flow_name, documentation): """ Connect this task spec to the indicated child, if the condition evaluates to true. This should only be called if the task has a connect_if method (e.g....
Returns a list of the names of outgoing sequences. Some may be None.
def get_outgoing_sequence_names(self): """ Returns a list of the names of outgoing sequences. Some may be None. """ return sorted([s.name for s in list(self.outgoing_sequence_flows_by_id.values())])
Connects a taskspec that is executed if the condition DOES match.
def connect_if(self, condition, task_spec): """ Connects a taskspec that is executed if the condition DOES match. condition -- a condition (Condition) taskspec -- the conditional task spec """ assert task_spec is not None self.outputs.append(task_spec) se...
Runs the task. Should not be called directly. Returns True if completed False otherwise.
def _on_complete_hook(self, my_task): """ Runs the task. Should not be called directly. Returns True if completed, False otherwise. """ # Find all matching conditions. outputs = [] for condition, output in self.cond_task_specs: if self.choice is not No...
Returns True if the entire Workflow is completed False otherwise.
def is_completed(self): """ Returns True if the entire Workflow is completed, False otherwise. :rtype: bool :return: Whether the workflow is completed. """ mask = Task.NOT_FINISHED_MASK iter = Task.Iterator(self.task_tree, mask) try: next(iter...
Cancels all open tasks in the workflow.
def cancel(self, success=False): """ Cancels all open tasks in the workflow. :type success: bool :param success: Whether the Workflow should be marked as successfully completed. """ self.success = success cancel = [] mask = Task.N...
Returns the task with the given id.
def get_task(self, id): """ Returns the task with the given id. :type id:integer :param id: The id of a task. :rtype: Task :returns: The task with the given id. """ tasks = [task for task in self.get_tasks() if task.id == id] return tasks[0] if le...
Returns all tasks whose spec has the given name.
def get_tasks_from_spec_name(self, name): """ Returns all tasks whose spec has the given name. :type name: str :param name: The name of a task spec. :rtype: Task :return: The task that relates to the spec with the given name. """ return [task for task in ...
Returns a list of Task objects with the given state.
def get_tasks(self, state=Task.ANY_MASK): """ Returns a list of Task objects with the given state. :type state: integer :param state: A bitmask of states. :rtype: list[Task] :returns: A list of tasks. """ return [t for t in Task.Iterator(self.task_tree,...
Runs the task with the given id.
def complete_task_from_id(self, task_id): """ Runs the task with the given id. :type task_id: integer :param task_id: The id of the Task object. """ if task_id is None: raise WorkflowException(self.spec, 'task_id is None') for task in self.task_tree:...
Runs the next task. Returns True if completed False otherwise.
def complete_next(self, pick_up=True, halt_on_manual=True): """ Runs the next task. Returns True if completed, False otherwise. :type pick_up: bool :param pick_up: When True, this method attempts to choose the next task not by searching beginning at the ...
Runs all branches until completion. This is a convenience wrapper around: meth: complete_next and the pick_up argument is passed along.
def complete_all(self, pick_up=True, halt_on_manual=True): """ Runs all branches until completion. This is a convenience wrapper around :meth:`complete_next`, and the pick_up argument is passed along. :type pick_up: bool :param pick_up: Passed on to each call of complet...
Returns a weak reference to the given method or function. If the callback argument is not None it is called as soon as the referenced function is garbage deleted.
def ref(function, callback=None): """ Returns a weak reference to the given method or function. If the callback argument is not None, it is called as soon as the referenced function is garbage deleted. :type function: callable :param function: The function to reference. :type callback: ca...
: param workflow: the workflow instance to serialize
def serialize_workflow(self, workflow, include_spec=False, **kwargs): """ :param workflow: the workflow instance to serialize :param include_spec: Always set to False (The CompactWorkflowSerializer only supports workflow serialization) """ if include_spec: ra...
: param s_state: the state of the workflow as returned by serialize_workflow
def deserialize_workflow(self, s_state, workflow_spec=None, read_only=False, **kwargs): """ :param s_state: the state of the workflow as returned by serialize_workflow :param workflow_spec: the Workflow Spec of the workflow (CompactWorkflowSerializer...
Create a new workflow instance from the given spec and arguments.
def new_workflow(self, workflow_spec, read_only=False, **kwargs): """ Create a new workflow instance from the given spec and arguments. :param workflow_spec: the workflow spec to use :param read_only: this should be in read only mode :param kwargs: Any extra kwargs passed to t...
Returns False when successfully fired True otherwise
def _start(self, my_task, force=False): """Returns False when successfully fired, True otherwise""" if (not hasattr(my_task, 'subprocess')) or my_task.subprocess is None: my_task.subprocess = subprocess.Popen(self.args, stderr=subprocess.STDO...
Setting force to True allows for changing a state after it COMPLETED. This would otherwise be invalid.
def _setstate(self, value, force=False): """ Setting force to True allows for changing a state after it COMPLETED. This would otherwise be invalid. """ if self._state == value: return if value < self._state and not force: raise WorkflowException(se...
Setting force to True allows for changing a state after it COMPLETED. This would otherwise be invalid.
def _set_state(self, state, force=True): """ Setting force to True allows for changing a state after it COMPLETED. This would otherwise be invalid. """ self._setstate(state, True) self.last_state_change = time.time()
Adds a new child and assigns the given TaskSpec to it.
def _add_child(self, task_spec, state=MAYBE): """ Adds a new child and assigns the given TaskSpec to it. :type task_spec: TaskSpec :param task_spec: The task spec that is assigned to the new child. :type state: integer :param state: The bitmask of states for the new ch...
Assigns a new thread id to the task.
def _assign_new_thread_id(self, recursive=True): """ Assigns a new thread id to the task. :type recursive: bool :param recursive: Whether to assign the id to children recursively. :rtype: bool :returns: The new thread id. """ self.__class__.thread_id_po...
This method syncs up the task s children with the given list of task specs. In other words::
def _sync_children(self, task_specs, state=MAYBE): """ This method syncs up the task's children with the given list of task specs. In other words:: - Add one child for each given TaskSpec, unless that child already exists. - Remove all children for which th...
Returns True if parent is in the list of ancestors returns False otherwise.
def _is_descendant_of(self, parent): """ Returns True if parent is in the list of ancestors, returns False otherwise. :type parent: Task :param parent: The parent that is searched in the ancestors. :rtype: bool :returns: Whether the parent was found. ""...
Returns the ancestor that has a task with the given task spec as a parent. If no such ancestor was found the root task is returned.
def _find_child_of(self, parent_task_spec): """ Returns the ancestor that has a task with the given task spec as a parent. If no such ancestor was found, the root task is returned. :type parent_task_spec: TaskSpec :param parent_task_spec: The wanted ancestor. :r...
Returns any descendants that have the given task spec assigned.
def _find_any(self, task_spec): """ Returns any descendants that have the given task spec assigned. :type task_spec: TaskSpec :param task_spec: The wanted task spec. :rtype: list(Task) :returns: The tasks objects that are attached to the given task spec. """ ...
Returns the ancestor that has the given task spec assigned. If no such ancestor was found the root task is returned.
def _find_ancestor(self, task_spec): """ Returns the ancestor that has the given task spec assigned. If no such ancestor was found, the root task is returned. :type task_spec: TaskSpec :param task_spec: The wanted task spec. :rtype: Task :returns: The ancestor....
Returns the ancestor that has a task with the given name assigned. Returns None if no such ancestor was found.
def _find_ancestor_from_name(self, name): """ Returns the ancestor that has a task with the given name assigned. Returns None if no such ancestor was found. :type name: str :param name: The name of the wanted task. :rtype: Task :returns: The ancestor. "...
Marks the task as ready for execution.
def _ready(self): """ Marks the task as ready for execution. """ if self._has_state(self.COMPLETED) or self._has_state(self.CANCELLED): return self._set_state(self.READY) self.task_spec._on_ready(self)
Returns a textual representation of this Task s state.
def get_state_name(self): """ Returns a textual representation of this Task's state. """ state_name = [] for state, name in list(self.state_names.items()): if self._has_state(state): state_name.append(name) return '|'.join(state_name)
Inherits the data from the parent.
def _inherit_data(self): """ Inherits the data from the parent. """ LOG.debug("'%s' inheriting data from '%s'" % (self.get_name(), self.parent.get_name()), extra=dict(data=self.parent.data)) self.set_data(**s...
Cancels the item if it was not yet completed and removes any children that are LIKELY.
def cancel(self): """ Cancels the item if it was not yet completed, and removes any children that are LIKELY. """ if self._is_finished(): for child in self.children: child.cancel() return self._set_state(self.CANCELLED) self...
Called by the associated task to let us know that its state has changed ( e. g. from FUTURE to COMPLETED. )
def complete(self): """ Called by the associated task to let us know that its state has changed (e.g. from FUTURE to COMPLETED.) """ self._set_state(self.COMPLETED) return self.task_spec._on_complete(self)
Returns the subtree as a string for debugging.
def get_dump(self, indent=0, recursive=True): """ Returns the subtree as a string for debugging. :rtype: str :returns: The debug information. """ dbg = (' ' * indent * 2) dbg += '%s/' % self.id dbg += '%s:' % self.thread_id dbg += ' Task of %s' %...
Parses args and evaluates any Attrib entries
def _eval_args(args, my_task): """Parses args and evaluates any Attrib entries""" results = [] for arg in args: if isinstance(arg, Attrib) or isinstance(arg, PathAttrib): results.append(valueof(my_task, arg)) else: results.append(arg) return results
Parses kwargs and evaluates any Attrib entries
def _eval_kwargs(kwargs, my_task): """Parses kwargs and evaluates any Attrib entries""" results = {} for kwarg, value in list(kwargs.items()): if isinstance(value, Attrib) or isinstance(value, PathAttrib): results[kwarg] = valueof(my_task, value) else: results[kwarg] ...
Make sure an object is JSON - serializable Use this to return errors and other info that does not need to be deserialized or does not contain important app data. Best for returning error info and such
def Serializable(o): """Make sure an object is JSON-serializable Use this to return errors and other info that does not need to be deserialized or does not contain important app data. Best for returning error info and such""" if isinstance(o, (str, dict, int)): return o else: try...
Sends Celery asynchronous call and stores async call information for retrieval laster
def _send_call(self, my_task): """Sends Celery asynchronous call and stores async call information for retrieval laster""" args, kwargs = None, None if self.args: args = _eval_args(self.args, my_task) if self.kwargs: kwargs = _eval_kwargs(self.kwargs, my_t...
Abort celery task and retry it
def _restart(self, my_task): """ Abort celery task and retry it""" if not my_task._has_state(Task.WAITING): raise WorkflowException(my_task, "Cannot refire a task that is not" "in WAITING state") # Check state of existing call and abort it (save hi...
Clear celery task data
def _clear_celery_task_data(self, my_task): """ Clear celery task data """ # Save history if 'task_id' in my_task.internal_data: # Save history for diagnostics/forensics history = my_task._get_internal_data('task_history', []) history.append(my_task._get_inter...
Returns False when successfully fired True otherwise
def _start(self, my_task, force=False): """Returns False when successfully fired, True otherwise""" # Deserialize async call if necessary if not hasattr(my_task, 'async_call') and \ my_task._get_internal_data('task_id') is not None: task_id = my_task._get_internal_da...
Returns list of ancestor task specs based on inputs
def ancestors(self): """Returns list of ancestor task specs based on inputs""" results = [] def recursive_find_ancestors(task, stack): for input in task.inputs: if input not in stack: stack.append(input) recursive_find_ancestor...
Defines the given data field ( s ) using the given name/ value pairs.
def set_data(self, **kwargs): """ Defines the given data field(s) using the given name/value pairs. """ for key in kwargs: if key in self.defines: msg = "Spec data %s can not be modified" % key raise WorkflowException(self, msg) self.da...
Connect the * following * task to this one. In other words the given task is added as an output task.
def connect(self, taskspec): """ Connect the *following* task to this one. In other words, the given task is added as an output task. :type taskspec: TaskSpec :param taskspec: The new output task. """ self.outputs.append(taskspec) taskspec._connect_notif...
Updates the branch such that all possible future routes are added.
def _predict(self, my_task, seen=None, looked_ahead=0): """ Updates the branch such that all possible future routes are added. Should NOT be overwritten! Instead, overwrite _predict_hook(). :type my_task: Task :param my_task: The associated task in the task tree. :type...
Typically this method should perform the following actions::
def _update_hook(self, my_task): """ Typically this method should perform the following actions:: - Update the state of the corresponding task. - Update the predictions for its successors. Returning non-False will cause the task to go into READY. Returning any o...
Return True on success False otherwise.
def _on_ready(self, my_task): """ Return True on success, False otherwise. :type my_task: Task :param my_task: The associated task in the task tree. """ assert my_task is not None self.test() # Acquire locks, if any. for lock in self.locks: ...
Return True on success False otherwise. Should not be overwritten overwrite _on_complete_hook () instead.
def _on_complete(self, my_task): """ Return True on success, False otherwise. Should not be overwritten, overwrite _on_complete_hook() instead. :type my_task: Task :param my_task: The associated task in the task tree. :rtype: boolean :returns: True on success, ...
Creates the package writing the data out to the provided file - like object.
def create_package(self): """ Creates the package, writing the data out to the provided file-like object. """ # Check that all files exist (and calculate the longest shared path # prefix): self.input_path_prefix = None for filename in self.input_files: ...
Writes a local file in to the zip file and adds it to the manifest dictionary
def write_file_to_package_zip(self, filename, src_filename): """ Writes a local file in to the zip file and adds it to the manifest dictionary :param filename: The zip file name :param src_filename: the local file name """ f = open(src_filename) with f: ...
Writes data to the zip file and adds it to the manifest dictionary
def write_to_package_zip(self, filename, data): """ Writes data to the zip file and adds it to the manifest dictionary :param filename: The zip file name :param data: the data """ self.manifest[filename] = md5hash(data) self.package_zip.writestr(filename, data)
Write the manifest content to the zip file. It must be a predictable order.
def write_manifest(self): """ Write the manifest content to the zip file. It must be a predictable order. """ config = configparser.ConfigParser() config.add_section('Manifest') for f in sorted(self.manifest.keys()): config.set('Manifest', f.replace(...
A subclass can override this method to provide additional parseing or validation. It should call the parent method first.
def pre_parse_and_validate(self, bpmn, filename): """ A subclass can override this method to provide additional parseing or validation. It should call the parent method first. :param bpmn: an lxml tree of the bpmn content :param filename: the source file name This must...
This is the Signavio specific editor hook for pre - parsing and validation.
def pre_parse_and_validate_signavio(self, bpmn, filename): """ This is the Signavio specific editor hook for pre-parsing and validation. A subclass can override this method to provide additional parseing or validation. It should call the parent method first. :param bpmn...
Signavio produces slightly invalid BPMN for call activity nodes... It is supposed to put a reference to the id of the called process in to the calledElement attribute. Instead it stores a string ( which is the name of the process - not its ID in our interpretation ) in an extension tag.
def _fix_call_activities_signavio(self, bpmn, filename): """ Signavio produces slightly invalid BPMN for call activity nodes... It is supposed to put a reference to the id of the called process in to the calledElement attribute. Instead it stores a string (which is the name of th...