Exemplo n.º 1
0
 def state_machine_to_dict(state_machine):
     from rafcon.core.storage.storage import get_storage_id_for_state
     dict_representation = {
         'root_state_storage_id': get_storage_id_for_state(state_machine.root_state),
         'state_machine_version': state_machine.version,
         'used_rafcon_version': rafcon.__version__,
         'creation_time': state_machine.creation_time,
     }
     return dict_representation
Exemplo n.º 2
0
    def state_machine_to_dict(state_machine):
        from rafcon.core.states.execution_state import ExecutionState
        from rafcon.core.storage.storage import get_storage_id_for_state
        dict_representation = {
            'state_machine_version': state_machine.version,
            'used_rafcon_version': rafcon.__version__,
            'creation_time': state_machine.creation_time,
            'last_update': state_machine.last_update,
        }
        if not isinstance(state_machine.root_state, ExecutionState):
            dict_representation['root_state_storage_id'] = get_storage_id_for_state(state_machine.root_state)

        return dict_representation
Exemplo n.º 3
0
def check_state_storage(state,
                        parent_path,
                        missing_elements,
                        existing_elements=None,
                        check_meta_data=False):
    from rafcon.core.states.execution_state import ExecutionState
    from rafcon.core.states.container_state import ContainerState
    from rafcon.core.storage import storage
    from rafcon.core.storage.storage import get_storage_id_for_state

    # check state folder exists
    folder_path = os.path.join(parent_path, get_storage_id_for_state(state))
    check_folder(folder_path, "state_path", missing_elements,
                 existing_elements)

    # check state script exists
    if isinstance(state, ExecutionState):
        file_path = os.path.join(parent_path, get_storage_id_for_state(state),
                                 storage.SCRIPT_FILE)
        check_file(file_path, "script", missing_elements, existing_elements)

    # check state-meta data exists (transitions and so on)
    file_path = os.path.join(parent_path, get_storage_id_for_state(state),
                             storage.FILE_NAME_CORE_DATA)
    check_file(file_path, "core data", missing_elements, existing_elements)

    # check if optional gui-meta-data exists
    if check_meta_data:
        # gtk gui meta data
        file_path = os.path.join(parent_path, get_storage_id_for_state(state),
                                 storage.FILE_NAME_META_DATA)
        check_file(file_path, "meta data", missing_elements, existing_elements)

    if isinstance(state, ContainerState):
        for key, child_state in state.states.items():
            check_state_storage(child_state, folder_path, missing_elements,
                                existing_elements, check_meta_data)