code stringlengths 1 18.2k |
|---|
# noqa # now convert the mappings into the .kibana format field_cache = [] for (index_name, val) in iteritems(es_mappings): if index_name != self.index: # only get non-'.kibana' indices # self.pr_dbg("index: %s" % index_name) m_dict = es_mappings[index_name]['mappings'] # self.pr_dbg('m_dict %s' % m_dict) mappings = se... |
def post_field_cache(self, field_cache): """Where field_cache is a list of fields' mappings""" index_pattern = self.field_cache_to_index_pattern(field_cache) # self.pr_dbg("request/post: %s" % index_pattern) resp = requests.post(self.post_url, data=index_pattern).text # resp = {"_index":".kibana","_type":"index-pattern... |
def field_cache_to_index_pattern(self, field_cache): """Return a .kibana index-pattern doc_type""" mapping_dict = {} mapping_dict['customFormats'] = "{}" mapping_dict['title'] = self.index_pattern # now post the data into .kibana mapping_dict['fields'] = json.dumps(field_cache, separators=(',', ':')) # in order to post... |
def check_mapping(self, m): """Assert minimum set of fields in cache, does not validate contents""" if 'name' not in m: self.pr_dbg("Missing %s" % "name") return False # self.pr_dbg("Checking %s" % m['name']) for x in ['analyzed', 'indexed', 'type', 'scripted', 'count']: if x not in m or m[x] == "": self.pr_dbg("Missin... |
== "": if not m['name'].startswith('_'): self.pr_dbg("Missing %s" % "doc_values") return False m['doc_values'] = False return True |
def get_index_mappings(self, index): """Converts all index's doc_types to .kibana""" fields_arr = [] for (key, val) in iteritems(index): # self.pr_dbg("\tdoc_type: %s" % key) doc_mapping = self.get_doc_type_mappings(index[key]) # self.pr_dbg("\tdoc_mapping: %s" % doc_mapping) if doc_mapping is None: return None # keep ... |
def get_doc_type_mappings(self, doc_type): """Converts all doc_types' fields to .kibana""" doc_fields_arr = [] found_score = False for (key, val) in iteritems(doc_type): # self.pr_dbg("\t\tfield: %s" % key) # self.pr_dbg("\tval: %s" % val) add_it = False retdict = {} # _ are system if not key.startswith('_'): if 'mappi... |
subkey_name = re.sub('.*\.', '', key) if subkey_name not in doc_type[key]['mapping']: self.pr_err( "Couldn't find subkey " + "doc_type[%s]['mapping'][%s]" % (key, subkey_name)) return None # self.pr_dbg("\t\tsubkey_name: %s" % subkey_name) retdict = self.get_field_mappings( doc_type[key]['mapping'][subkey_name]) add_it... |
self.get_field_mappings( doc_type[key]['mapping'][key]) retdict['type'] = "_source" elif key == '_score': retdict['type'] = "number" elif 'type' not in retdict: retdict['type'] = "string" add_it = True if add_it: retdict['name'] = key retdict['count'] = 0 # always init to 0 retdict['scripted'] = False # I haven't obser... |
# make the array here, after all collected, then escape it doc_fields_arr.append(retdict) if not found_score: doc_fields_arr.append( {"name": "_score", "type": "number", "count": 0, "scripted": False, "indexed": False, "analyzed": False, "doc_values": False}) return doc_fields_arr |
def get_field_mappings(self, field): """Converts ES field mappings to .kibana field mappings""" retdict = {} retdict['indexed'] = False retdict['analyzed'] = False for (key, val) in iteritems(field): if key in self.mappings: if (key == 'type' and (val == "long" or val == "integer" or val == "double" or val == "float"))... |
val if key == 'index' and val != "no": retdict['indexed'] = True # self.pr_dbg("\t\t\tkey: %s" % key) # self.pr_dbg("\t\t\t\tval: %s" % val) if val == "analyzed": retdict['analyzed'] = True return retdict |
def is_kibana_cache_incomplete(self, es_cache, k_cache): """Test if k_cache is incomplete Assume k_cache is always correct, but could be missing new fields that es_cache has """ # convert list into dict, with each item's ['name'] as key k_dict = {} for field in k_cache: # self.pr_dbg("field: %s" % field) k_dict[field['... |
es_dict[field['name']] = field for ign_f in self.mappings_ignore: es_dict[field['name']][ign_f] = 0 es_set = set(es_dict.keys()) k_set = set(k_dict.keys()) # reasons why kibana cache could be incomplete: # k_dict is missing keys that are within es_dict # We don't care if k has keys that es doesn't # es {1,2} k {1,2,3};... |
{1,2} k {}; intersection {}; len(es-{}) 2 # es {1,2} k {1}; intersection {1}; len(es-{}) 1 # es {2,3} k {1}; intersection {}; len(es-{}) 2 # es {2,3} k {1,2}; intersection {2}; len(es-{}) 1 return len(es_set - k_set.intersection(es_set)) > 0 |
def list_to_compare_dict(self, list_form): """Convert list into a data structure we can query easier""" compare_dict = {} for field in list_form: if field['name'] in compare_dict: self.pr_dbg("List has duplicate field %s:\n%s" % (field['name'], compare_dict[field['name']])) if compare_dict[field['name']] != field: self... |
def compare_field_caches(self, replica, original): """Verify original is subset of replica""" if original is None: original = [] if replica is None: replica = [] self.pr_dbg("Comparing orig with %s fields to replica with %s fields" % (len(original), len(replica))) # convert list into dict, with each item's ['name'] as ... |
if repl is None: self.pr_dbg("Replica has duplicate fields") return 1 # search orig for each item in repl # if any items in repl not within orig or vice versa, then complain # make sure contents of each item match orig_found = {} for (key, field) in iteritems(repl): field_name = field['name'] if field_name not in orig:... |
%s" % (field_name, field)) return 1 orig_found[field_name] = True if orig[field_name] != field: self.pr_dbg("Field in replica doesn't match orig:") self.pr_dbg("orig:%s\nrepl:%s" % (orig[field_name], field)) return 1 unfound = set(orig_found.keys()) - set(repl.keys()) if len(unfound) > 0: self.pr_dbg("Orig contains fie... |
- set(orig_found.keys()) # if len(unfound) > 0: # self.pr_dbg("Replica contains fields that were not in orig") # self.pr_dbg('%s' % unfound) # return 1 self.pr_dbg("Original matches replica") return 0 |
def start_daemon_thread(target, args=()): """starts a deamon thread for a given target function and arguments.""" th = Thread(target=target, args=args) th.daemon = True th.start() return th |
def serialize_dict_keys(d, prefix=""): """returns all the keys in a dictionary. >>> serialize_dict_keys({"a": {"b": {"c": 1, "b": 2} } }) ['a', 'a.b', 'a.b.c', 'a.b.b'] """ keys = [] for k, v in d.iteritems(): fqk = '%s%s' % (prefix, k) keys.append(fqk) if isinstance(v, dict): keys.extend(serialize_dict_keys(v, prefix=... |
def set_user(self, user): """ Writes user data to session. Args: user: User object """ self.session['user_id'] = user.key self.session['user_data'] = user.clean_value() role = self.get_role() # TODO: this should be remembered from previous login # self.session['role_data'] = default_role.clean_value() self.session['rol... |
def contains_opposite_color_piece(self, square, position): """ Finds if square on the board is occupied by a ``Piece`` belonging to the opponent. :type: square: Location :type: position: Board :rtype: bool """ return not position.is_square_empty(square) and \ position.piece_at_square(square).color != self.color |
def gettext(message, domain=DEFAULT_DOMAIN): """Mark a message as translateable, and translate it. All messages in the application that are translateable should be wrapped with this function. When importing this function, it should be renamed to '_'. For example: .. code-block:: python from zengine.lib.translation impo... |
formatting, key-based formatting should be used. This gives the translator an idea what the variables in the format are going to be, and makes it possible for the translator to reorder the variables. For example: .. code-block:: python name, number = 'Elizabeth', 'II' _('Queen %(name)s %(number)s') % {'name': name, 'nu... |
of the current user. If this function is called before a language is installed (which is normally done by ZEngine when the user connects), this function will simply return the message without modification. If there are messages containing unicode characters, in Python 2 these messages must be marked as unicode. Otherwi... |
example: .. code-block:: python print(_('Café')) 'Café' print(_(u'Café')) 'Kahve' Args: message (basestring, unicode): The input message. domain (basestring): The domain of the message. Defaults to 'messages', which is the domain where all application messages should be located. Returns: unicode: The translated message... |
def gettext_lazy(message, domain=DEFAULT_DOMAIN): """Mark a message as translatable, but delay the translation until the message is used. Sometimes, there are some messages that need to be translated, but the translation can't be done at the point the message itself is written. For example, the names of the fields in a... |
be done when the file is imported, long before a user even connects. To avoid this, `gettext_lazy` should be used. For example: .. code-block:: python from zengine.lib.translation import gettext_lazy, InstalledLocale from pyoko import model, fields class User(model.Model): name = fields.String(gettext_lazy('User Name')... |
'messages', which is the domain where all application messages should be located. Returns: unicode: The translated message, with the translation itself being delayed until the text is actually used. """ return LazyProxy(gettext, message, domain=domain, enable_cache=False) |
def ngettext(singular, plural, n, domain=DEFAULT_DOMAIN): """Mark a message as translateable, and translate it considering plural forms. Some messages may need to change based on a number. For example, consider a message like the following: .. code-block:: python def alert_msg(msg_count): print( 'You have %d %s' % (msg... |
translate this message, you can use ngettext to consider the plural forms: .. code-block:: python from zengine.lib.translation import ngettext def alert_msg(msg_count): print(ngettext('You have %(count)d message', 'You have %(count)d messages', msg_count) % {'count': msg_count}) alert_msg(1) '1 mesajınız var' alert_msg... |
of the message. plural (unicode): The plural form of the message. n (int): The number that is used to decide which form should be used. domain (basestring): The domain of the message. Defaults to 'messages', which is the domain where all application messages should be located. Returns: unicode: The correct pluralizatio... |
def ngettext_lazy(singular, plural, n, domain=DEFAULT_DOMAIN): """Mark a message with plural forms translateable, and delay the translation until the message is used. Works the same was a `ngettext`, with a delaying functionality similiar to `gettext_lazy`. Args: singular (unicode): The singular form of the message. pl... |
used. domain (basestring): The domain of the message. Defaults to 'messages', which is the domain where all application messages should be located. Returns: unicode: The correct pluralization, with the translation being delayed until the message is used. """ return LazyProxy(ngettext, singular, plural, n, domain=domain... |
def _wrap_locale_formatter(fn, locale_type): """Wrap a Babel data formatting function to automatically format for currently installed locale.""" def wrapped_locale_formatter(*args, **kwargs): """A Babel formatting function, wrapped to automatically use the currently installed language. The wrapped function will not thr... |
can be overriden by passing it a `locale` keyword. To learn more about this function, check the documentation of Babel for the function of the same name. """ # Get the current locale from the class kwargs_ = {'locale': getattr(InstalledLocale, locale_type)} # By creating a dict then updating it, we allow locale to be o... |
"""Can\'t do formatting for language code {locale}, falling back to default {default}""".format( locale=kwargs_['locale'], default=settings.DEFAULT_LANG) ) kwargs_['locale'] = settings.DEFAULT_LANG formatted = fn(*args, **kwargs_) return formatted return wrapped_locale_formatter |
def install_language(cls, language_code): """Install the translations for language specified by `language_code`. If we don't have translations for this language, then the default language will be used. If the language specified is already installed, then this is a no-op. """ # Skip if the language is already installed ... |
KeyError: default = settings.DEFAULT_LANG log.warning('Unknown language %s, falling back to %s', language_code, default) cls._active_catalogs = cls._translation_catalogs[default] cls.language = default |
def install_locale(cls, locale_code, locale_type): """Install the locale specified by `language_code`, for localizations of type `locale_type`. If we can't perform localized formatting for the specified locale, then the default localization format will be used. If the locale specified is already installed for the selec... |
try: # We create a Locale instance to see if the locale code is supported locale = Locale(locale_code) log.debug('Installed locale %s', locale_code) except UnknownLocaleError: default = settings.DEFAULT_LOCALIZATION_FORMAT log.warning('Unknown locale %s, falling back to %s', locale_code, default) locale = Locale(defaul... |
def _rotate_vector(x, y, x2, y2, x1, y1): """ rotate x,y vector over x2-x1, y2-y1 angle """ angle = atan2(y2 - y1, x2 - x1) cos_rad = cos(angle) sin_rad = sin(angle) return cos_rad * x + sin_rad * y, -sin_rad * x + cos_rad * y |
def _build_static_table_mapping(): """ Build static table mapping from header name to tuple with next structure: (<minimal index of header>, <mapping from header value to it index>). static_table_mapping used for hash searching. """ static_table_mapping = {} for index, (name, value) in enumerate(CocaineHeaders.STATIC_T... |
def get_by_index(self, index): """ Returns the entry specified by index Note that the table is 1-based ie an index of 0 is invalid. This is due to the fact that a zero value index signals that a completely unindexed header follows. The entry will either be from the static table or the dynamic table depending on the val... |
if 0 <= index < len(CocaineHeaders.STATIC_TABLE): return CocaineHeaders.STATIC_TABLE[index] index -= len(CocaineHeaders.STATIC_TABLE) if 0 <= index < len(self.dynamic_entries): return self.dynamic_entries[index] raise InvalidTableIndex("Invalid table index %d" % index) |
def add(self, name, value): """ Adds a new entry to the table We reduce the table size if the entry will make the table size greater than maxsize. """ # We just clear the table if the entry is too big size = table_entry_size(name, value) if size > self._maxsize: self.dynamic_entries.clear() self._current_size = 0 # Add... |
elif self._maxsize > 0: self.dynamic_entries.appendleft((name, value)) self._current_size += size self._shrink() |
def search(self, name, value): """ Searches the table for the entry specified by name and value Returns one of the following: - ``None``, no match at all - ``(index, name, None)`` for partial matches on name only. - ``(index, name, value)`` for perfect matches. """ partial = None header_name_search_result = CocaineHead... |
value partial = (header_name_search_result[0], name, None) offset = len(CocaineHeaders.STATIC_TABLE) for (i, (n, v)) in enumerate(self.dynamic_entries): if n == name: if v == value: return i + offset + 1, n, v elif partial is None: partial = (i + offset + 1, n, None) return partial |
def _shrink(self): """ Shrinks the dynamic table to be at or below maxsize """ cursize = self._current_size while cursize > self._maxsize: name, value = self.dynamic_entries.pop() cursize -= table_entry_size(name, value) self._current_size = cursize |
def add(self, name, value): # type: (str, str) -> None """Adds a new value for the given key.""" self._last_key = name if name in self: self._dict[name] = value self._as_list[name].append(value) else: self[name] = value |
def get_all(self): # type: () -> typing.Iterable[typing.Tuple[str, str]] """Returns an iterable of all (name, value) pairs. If a header has multiple values, multiple pairs will be returned with the same name. """ for name, values in six.iteritems(self._as_list): for value in values: yield (name, value) |
def safe_print(ustring, errors='replace', **kwargs): """ Safely print a unicode string """ encoding = sys.stdout.encoding or 'utf-8' if sys.version_info[0] == 3: print(ustring, **kwargs) else: bytestr = ustring.encode(encoding, errors=errors) print(bytestr, **kwargs) |
def edit_permissions(self): """Creates the view used to edit permissions. To create the view, data in the following format is passed to the UI in the objects field: .. code-block:: python { "type": "tree-toggle", "action": "set_permission", "tree": [ { "checked": true, "name": "Workflow 1 Name", "id": "workflow1", "chi... |
"workflow1..task2", "name": "Task 2 Name", "children": [] } ] }, { "checked": true, "name": "Workflow 2 Name", "id": "workflow2", "children": [ { "checked": true, "name": "Workflow 2 Lane 1 Name", "id": "workflow2.lane1", "children": [ { "checked": true, "name": "Workflow 2 Task 1 Name", "id": "workflow2.lane1.task1", ... |
] } ] } "type" field denotes that the object is a tree view which has elements that can be toggled. "action" field is the "name" field is the human readable name. "id" field is used to make requests to the backend. "checked" field shows whether the role has the permission or not. "children" field is the sub-permissions... |
the role that was selected in the CRUD view key = self.current.input['object_id'] self.current.task_data['role_id'] = key role = RoleModel.objects.get(key=key) # Get the cached permission tree, or build a new one if there is none cached # TODO: Add an extra view in case there was no cache, as in 'please wait calculatin... |
setting the 'checked' field # of the permission the role has role_tree = self._apply_role_tree(permission_tree, role) # Apply final formatting, and output the tree to the UI self.output['objects'] = [ { 'type': 'tree-toggle', 'action': 'apply_change', 'trees': self._format_tree_output(role_tree), }, ] self.form_out(Per... |
def _permission_trees(permissions): """Get the cached permission tree, or build a new one if necessary.""" treecache = PermissionTreeCache() cached = treecache.get() if not cached: tree = PermissionTreeBuilder() for permission in permissions: tree.insert(permission) result = tree.serialize() treecache.set(result) retur... |
def _apply_role_tree(self, perm_tree, role): """In permission tree, sets `'checked': True` for the permissions that the role has.""" role_permissions = role.get_permissions() for perm in role_permissions: self._traverse_tree(perm_tree, perm)['checked'] = True return perm_tree |
def _traverse_tree(tree, path): """Traverses the permission tree, returning the permission at given permission path.""" path_steps = (step for step in path.split('.') if step != '') # Special handling for first step, because the first step isn't under 'objects' first_step = path_steps.next() subtree = tree[first_step] ... |
def _format_subtree(self, subtree): """Recursively format all subtrees.""" subtree['children'] = list(subtree['children'].values()) for child in subtree['children']: self._format_subtree(child) return subtree |
def apply_change(self): """Applies changes to the permissions of the role. To make a change to the permission of the role, a request in the following format should be sent: .. code-block:: python { 'change': { 'id': 'workflow2.lane1.task1', 'checked': false }, } The 'id' field of the change is the id of the tree elemen... |
is the new state of the element. """ changes = self.input['change'] key = self.current.task_data['role_id'] role = RoleModel.objects.get(key=key) for change in changes: permission = PermissionModel.objects.get(code=change['id']) if change['checked'] is True: role.add_permission(permission) else: role.remove_permission(... |
def seek(self, offset): """ shifts on a given number of record in the original file :param offset: number of record """ if self._shifts: if 0 <= offset < len(self._shifts): current_pos = self._file.tell() new_pos = self._shifts[offset] if current_pos != new_pos: if current_pos == self._shifts[-1]: # reached the end of ... |
self._implement_error |
def tell(self): """ :return: number of records processed from the original file """ if self._shifts: t = self._file.tell() return bisect_left(self._shifts, t) raise self._implement_error |
def write(self, data): """ write single molecule into file """ m = self._convert_structure(data) self._file.write(self._format_mol(*m)) self._file.write('M END\n') for k, v in data.meta.items(): self._file.write(f'> <{k}>\n{v}\n') self._file.write('$$$$\n') |
def save_workflow_to_cache(self, serialized_wf_instance): """ If we aren't come to the end of the wf, saves the wf state and task_data to cache Task_data items that starts with underscore "_" are treated as local and does not passed to subsequent task steps. """ # self.current.task_data['flow'] = None task_data = self.... |
self.wf_state.update({'step': serialized_wf_instance, 'data': task_data, 'name': self.current.workflow_name, 'wf_id': self.workflow_spec.wf_id }) if self.current.lane_id: self.current.pool[self.current.lane_id] = self.current.role.key self.wf_state['pool'] = self.current.pool self.current.log.debug("POOL Content before... |
def get_pool_context(self): # TODO: Add in-process caching """ Builds context for the WF pool. Returns: Context dict. """ context = {self.current.lane_id: self.current.role, 'self': self.current.role} for lane_id, role_id in self.current.pool.items(): if role_id: context[lane_id] = lazy_object_proxy.Proxy( lambda: self... |
def load_workflow_from_cache(self): """ loads the serialized wf state and data from cache updates the self.current.task_data """ if not self.current.new_token: self.wf_state = self.current.wf_cache.get(self.wf_state) self.current.task_data = self.wf_state['data'] self.current.set_client_cmds() self.current.pool = self.... |
def serialize_workflow(self): """ Serializes the current WF. Returns: WF state data. """ self.workflow.refresh_waiting_tasks() return CompactWorkflowSerializer().serialize_workflow(self.workflow, include_spec=False) |
def load_or_create_workflow(self): """ Tries to load the previously serialized (and saved) workflow Creates a new one if it can't """ self.workflow_spec = self.get_worfklow_spec() return self._load_workflow() or self.create_workflow() |
def find_workflow_path(self): """ Tries to find the path of the workflow diagram file in `WORKFLOW_PACKAGES_PATHS`. Returns: Path of the workflow spec file (BPMN diagram) """ for pth in settings.WORKFLOW_PACKAGES_PATHS: path = "%s/%s.bpmn" % (pth, self.current.workflow_name) if os.path.exists(path): return path err_msg... |
def get_worfklow_spec(self): """ Generates and caches the workflow spec package from BPMN diagrams that read from disk Returns: SpiffWorkflow Spec object. """ # TODO: convert from in-process to redis based caching if self.current.workflow_name not in self.workflow_spec_cache: # path = self.find_workflow_path() # spec_p... |
xml_content = self.current.wf_object.xml.body spec = ZopsSerializer().deserialize_workflow_spec(xml_content, self.current.workflow_name) spec.wf_id = self.current.wf_object.key self.workflow_spec_cache[self.current.workflow_name] = spec return self.workflow_spec_cache[self.current.workflow_name] |
def _save_or_delete_workflow(self): """ Calls the real save method if we pass the beggining of the wf """ if not self.current.task_type.startswith('Start'): if self.current.task_name.startswith('End') and not self.are_we_in_subprocess(): self.wf_state['finished'] = True self.wf_state['finish_date'] = datetime.now().str... |
def start_engine(self, **kwargs): """ Initializes the workflow with given request, response objects and diagram name. Args: session: input: workflow_name (str): Name of workflow diagram without ".bpmn" suffix. File must be placed under one of configured :py:attr:`~zengine.settings.WORKFLOW_PACKAGES_PATHS` """ self.curr... |
with, # inserting it as current.input['id'] and task_data['object_id'] if 'subject' in self.wf_state: self.current.input['id'] = self.wf_state['subject'] self.current.task_data['object_id'] = self.wf_state['subject'] self.check_for_authentication() self.check_for_permission() self.workflow = self.load_or_create_workflo... |
True # demanded initial values are assigned and put to cache start_init_values = self.workflow_spec.wf_properties.get('init', 'False') == 'True' if start_init_values: WFInit = get_object_from_path(settings.WF_INITIAL_VALUES)() WFInit.assign_wf_initial_values(self.current) log_msg = ("\n\n::::::::::: ENGINE STARTED ::::... |
def generate_wf_state_log(self): """ Logs the state of workflow and content of task_data. """ output = '\n- - - - - -\n' output += "WORKFLOW: %s ( %s )" % (self.current.workflow_name.upper(), self.current.workflow.name) output += "\nTASK: %s ( %s )\n" % (self.current.task_name, self.current.task_type) output += "DATA:"... |
%s" % self.current.activity output += "\n\tPOOL: %s" % self.current.pool output += "\n\tIN EXTERNAL: %s" % self.wf_state['in_external'] output += "\n\tLANE: %s" % self.current.lane_name output += "\n\tTOKEN: %s" % self.current.token sys._zops_wf_state_log = output return output |
def switch_from_external_to_main_wf(self): """ Main workflow switcher. This method recreates main workflow from `main wf` dict which was set by external workflow swicther previously. """ # in external assigned as True in switch_to_external_wf. # external_wf should finish EndEvent and it's name should be # also EndEvent... |
information was copied in switch_to_external_wf and it takes this information. main_wf = self.wf_state['main_wf'] # main_wf_name is assigned to current workflow name again. self.current.workflow_name = main_wf['name'] # For external WF, check permission and authentication. But after cleaning current task. self._clear_c... |
self.get_worfklow_spec() # WF instance is started again where leave off. self.workflow = self.deserialize_workflow(main_wf['step']) # Current WF is this WF instance. self.current.workflow = self.workflow # in_external is assigned as False self.wf_state['in_external'] = False # finished is assigned as False, because sti... |
def switch_to_external_wf(self): """ External workflow switcher. This method copies main workflow information into a temporary dict `main_wf` and makes external workflow acting as main workflow. """ # External WF name should be stated at main wf diagram and type should be service task. if (self.current.task_type == 'Se... |
= self.wf_state.copy() # workflow name from main wf diagram is assigned to current workflow name. # workflow name must be either in task_data with key 'external_wf' or in main diagram's # topic. self.current.workflow_name = self.current.task_data.pop('external_wf', False) or self.\ current.task.task_spec.topic # For ex... |
new workflow_name self.check_for_authentication() self.check_for_permission() # wf knowledge is taken for external wf. self.workflow_spec = self.get_worfklow_spec() # New WF instance is created for external wf. self.workflow = self.create_workflow() # Current WF is this WF instance. self.current.workflow = self.workflo... |
self.wf_state = {'main_wf': main_wf, 'in_external': True, 'finished': False} |
def _clear_current_task(self): """ Clear tasks related attributes, checks permissions While switching WF to WF, authentication and permissions are checked for new WF. """ self.current.task_name = None self.current.task_type = None self.current.task = None |
def run(self): """ Main loop of the workflow engine - Updates ::class:`~WFCurrent` object. - Checks for Permissions. - Activates all READY tasks. - Runs referenced activities (method calls). - Saves WF states. - Stops if current task is a UserTask or EndTask. - Deletes state object if we finish the WF. """ # FIXME: rai... |
# FIXME: raise if last task of a workflow is a UserTask # actually this check should be done at parser is_lane_changed = False while self._should_we_run(): self.check_for_rerun_user_task() task = None for task in self.workflow.get_tasks(state=Task.READY): self.current.old_lane = self.current.lane_name self.current._upd... |
task(s) for task in self.workflow.get_tasks(state=Task.READY): self.current._update_task(task) self.catch_lane_change() self.handle_wf_finalization() |
def check_for_rerun_user_task(self): """ Checks that the user task needs to re-run. If necessary, current task and pre task's states are changed and re-run. If wf_meta not in data(there is no user interaction from pre-task) and last completed task type is user task and current step is not EndEvent and there is no lane ... |
'wf_meta' in data: return current_task = self.workflow.get_tasks(Task.READY)[0] current_task_type = current_task.task_spec.__class__.__name__ pre_task = current_task.parent pre_task_type = pre_task.task_spec.__class__.__name__ if pre_task_type != 'UserTask': return if current_task_type == 'EndEvent': return pre_lane = ... |
def switch_lang(self): """Switch to the language of the current user. If the current language is already the specified one, nothing will be done. """ locale = self.current.locale translation.InstalledLocale.install_language(locale['locale_language']) translation.InstalledLocale.install_locale(locale['locale_datetime'],... |
def catch_lane_change(self): """ trigger a lane_user_change signal if we switched to a new lane and new lane's user is different from current one """ if self.current.lane_name: if self.current.old_lane and self.current.lane_name != self.current.old_lane: # if lane_name not found in pool or it's user different from the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.