idx
int64
0
63k
question
stringlengths
53
5.28k
target
stringlengths
5
805
40,500
def remove_controller ( self , controller ) : if isinstance ( controller , ExtendedController ) : for key , child_controller in self . __child_controllers . items ( ) : if controller is child_controller : break else : return False else : key = controller if key in self . __child_controllers : if self . __shortcut_manag...
Remove child controller and destroy it
40,501
def register_actions ( self , shortcut_manager ) : assert isinstance ( shortcut_manager , ShortcutManager ) self . __shortcut_manager = shortcut_manager for controller in list ( self . __child_controllers . values ( ) ) : if controller not in self . __action_registered_controllers : try : controller . register_actions ...
Register callback methods for triggered actions in all child controllers .
40,502
def destroy ( self ) : self . disconnect_all_signals ( ) controller_names = [ key for key in self . __child_controllers ] for controller_name in controller_names : self . remove_controller ( controller_name ) self . relieve_all_models ( ) if self . parent : self . __parent = None if self . _view_initialized : self . vi...
Recursively destroy all Controllers
40,503
def observe_model ( self , model ) : self . __registered_models . add ( model ) return super ( ExtendedController , self ) . observe_model ( model )
Make this model observable within the controller
40,504
def relieve_model ( self , model ) : self . __registered_models . remove ( model ) return super ( ExtendedController , self ) . relieve_model ( model )
Do no longer observe the model
40,505
def relieve_all_models ( self ) : map ( self . relieve_model , list ( self . __registered_models ) ) self . __registered_models . clear ( )
Relieve all registered models
40,506
def change_data_type ( self , data_type , default_value = None ) : old_data_type = self . data_type self . data_type = data_type if default_value is None : default_value = self . default_value if type_helpers . type_inherits_of_type ( type ( default_value ) , self . _data_type ) : self . _default_value = default_value ...
This method changes both the data type and default value . If one of the parameters does not fit an exception is thrown and no property is changed . Using this method ensures a consistent data type and default value and only notifies once .
40,507
def check_default_value ( self , default_value , data_type = None ) : if data_type is None : data_type = self . data_type if default_value is not None : if isinstance ( default_value , string_types ) : if len ( default_value ) > 1 and default_value [ 0 ] == '$' : return default_value if default_value == "None" : return...
Check whether the passed default value suits to the passed data type . If no data type is passed the data type of the data port is used . If the default value does not fit an exception is thrown . If the default value is of type string it is tried to convert that value to the data type .
40,508
def create_folder_cmd_line ( query , default_name = None , default_path = None ) : default = None if default_name and default_path : default = os . path . join ( default_path , default_name ) user_input = input ( query + ' [default {}]: ' . format ( default ) ) if len ( user_input ) == 0 : user_input = default if not u...
Queries the user for a path to be created
40,509
def save_folder_cmd_line ( query , default_name = None , default_path = None ) : default = None if default_name and default_path : default = os . path . join ( default_path , default_name ) user_input = input ( query + ' [default {}]: ' . format ( default ) ) if len ( user_input ) == 0 : user_input = default if not use...
Queries the user for a path or file to be saved into
40,510
def remove_core_element ( self , model ) : assert model . transition . parent is self . model . state or model . transition . parent is self . model . parent . state gui_helper_state_machine . delete_core_element_of_model ( model )
Remove respective core element of handed transition model
40,511
def _update_internal_data_base ( self ) : model = self . model self . combo [ 'internal' ] = { } self . combo [ 'external' ] = { } self . combo [ 'free_from_states' ] = { } self . combo [ 'free_from_outcomes_dict' ] = { } self . combo [ 'free_ext_from_outcomes_dict' ] = { } self . combo [ 'free_ext_from_outcomes_dict' ...
Updates Internal combo knowledge for any actual transition by calling get_possible_combos_for_transition - function for those .
40,512
def move_dirty_lock_file ( dirty_lock_file , sm_path ) : if dirty_lock_file is not None and not dirty_lock_file == os . path . join ( sm_path , dirty_lock_file . split ( os . sep ) [ - 1 ] ) : logger . debug ( "Move dirty lock from root tmp folder {0} to state machine folder {1}" "" . format ( dirty_lock_file , os . pa...
Move the dirt_lock file to the sm_path and thereby is not found by auto recovery of backup anymore
40,513
def write_backup_meta_data ( self ) : auto_backup_meta_file = os . path . join ( self . _tmp_storage_path , FILE_NAME_AUTO_BACKUP ) storage . storage_utils . write_dict_to_json ( self . meta , auto_backup_meta_file )
Write the auto backup meta data into the current tmp - storage path
40,514
def update_last_backup_meta_data ( self ) : self . meta [ 'last_backup' ] [ 'time' ] = get_time_string_for_float ( self . last_backup_time ) self . meta [ 'last_backup' ] [ 'file_system_path' ] = self . _tmp_storage_path self . meta [ 'last_backup' ] [ 'marked_dirty' ] = self . state_machine_model . state_machine . mar...
Update the auto backup meta data with internal recovery information
40,515
def update_last_sm_origin_meta_data ( self ) : self . meta [ 'last_saved' ] [ 'time' ] = self . state_machine_model . state_machine . last_update self . meta [ 'last_saved' ] [ 'file_system_path' ] = self . state_machine_model . state_machine . file_system_path
Update the auto backup meta data with information of the state machine origin
40,516
def _check_for_dyn_timed_auto_backup ( self ) : current_time = time . time ( ) self . timer_request_lock . acquire ( ) if self . _timer_request_time is None : return self . timer_request_lock . release ( ) if self . timed_temp_storage_interval < current_time - self . _timer_request_time : self . check_for_auto_backup (...
The method implements the timed storage feature .
40,517
def check_for_auto_backup ( self , force = False ) : if not self . timed_temp_storage_enabled : return sm = self . state_machine_model . state_machine current_time = time . time ( ) if not self . only_fix_interval and not self . marked_dirty : self . last_backup_time = current_time is_not_timed_or_reached_time_to_force...
The method implements the checks for possible auto backup of the state - machine according duration till the last change together with the private method _check_for_dyn_timed_auto_backup .
40,518
def on_mouse_click ( self , widget , event ) : import rafcon . gui . helpers . state_machine as gui_helper_state_machine if self . view . get_path_at_pos ( int ( event . x ) , int ( event . y ) ) is not None and len ( self . view . get_selected_items ( ) ) > 0 : return gui_helper_state_machine . insert_state_into_selec...
state insertion on mouse click
40,519
def on_mouse_motion ( self , widget , event ) : path = self . view . get_path_at_pos ( int ( event . x ) , int ( event . y ) ) if path is not None : self . view . select_path ( path ) else : self . view . unselect_all ( )
selection on mouse over
40,520
def _get_state ( self ) : selected = self . view . get_selected_items ( ) if not selected : return shorthand , state_class = self . view . states [ selected [ 0 ] [ 0 ] ] return state_class ( )
get state instance which was clicked on
40,521
def apply_new_outcome_name ( self , path , new_name ) : if new_name == self . list_store [ path ] [ self . NAME_STORAGE_ID ] : return outcome = self . list_store [ path ] [ self . CORE_STORAGE_ID ] try : outcome . name = new_name logger . debug ( "Outcome name changed to '{0}'" . format ( outcome . name ) ) except ( Va...
Apply the newly entered outcome name it is was changed
40,522
def on_to_state_edited ( self , renderer , path , new_state_identifier ) : def do_self_transition_check ( t_id , new_state_identifier ) : if 'self' in new_state_identifier . split ( '.' ) : insert_self_transition_meta_data ( self . model , t_id , 'outcomes_widget' , combined_action = True ) outcome_id = self . list_sto...
Connects the outcome with a transition to the newly set state
40,523
def on_to_outcome_edited ( self , renderer , path , new_outcome_identifier ) : if self . model . parent is None : return outcome_id = self . list_store [ path ] [ self . ID_STORAGE_ID ] transition_parent_state = self . model . parent . state if outcome_id in self . dict_to_other_state or outcome_id in self . dict_to_ot...
Connects the outcome with a transition to the newly set outcome
40,524
def remove_core_element ( self , model ) : assert model . outcome . parent is self . model . state gui_helper_state_machine . delete_core_element_of_model ( model )
Remove respective core element of handed outcome model
40,525
def bring_tab_to_the_top ( self , tab_label ) : page = self . page_dict [ tab_label ] for notebook in self . notebook_names : page_num = self [ notebook ] . page_num ( page ) if not page_num == - 1 : self [ notebook ] . set_current_page ( page_num ) break
Find tab with label tab_label in list of notebook s and set it to the current page .
40,526
def compare_variables ( tree_model , iter1 , iter2 , user_data = None ) : path1 = tree_model . get_path ( iter1 ) [ 0 ] path2 = tree_model . get_path ( iter2 ) [ 0 ] name1 = tree_model [ path1 ] [ 0 ] name2 = tree_model [ path2 ] [ 0 ] name1_as_bits = ' ' . join ( format ( ord ( x ) , 'b' ) for x in name1 ) name2_as_bi...
Triggered upon updating the list of global variables
40,527
def reset_dirty_flags ( self ) : for sm_id , sm in self . state_machines . items ( ) : sm . marked_dirty = False
Set all marked_dirty flags of the state machine to false .
40,528
def add_state_machine ( self , state_machine ) : if not isinstance ( state_machine , StateMachine ) : raise AttributeError ( "State machine must be of type StateMachine" ) if state_machine . file_system_path is not None : if self . is_state_machine_open ( state_machine . file_system_path ) : raise AttributeError ( "The...
Add a state machine to the list of managed state machines . If there is no active state machine set yet then set as active state machine .
40,529
def remove_state_machine ( self , state_machine_id ) : import rafcon . core . singleton as core_singletons removed_state_machine = None if state_machine_id in self . _state_machines : logger . debug ( "Remove state machine with id {0}" . format ( state_machine_id ) ) removed_state_machine = self . _state_machines . pop...
Remove the state machine for a specified state machine id from the list of registered state machines .
40,530
def get_active_state_machine ( self ) : if self . _active_state_machine_id in self . _state_machines : return self . _state_machines [ self . _active_state_machine_id ] else : return None
Return a reference to the active state - machine
40,531
def get_open_state_machine_of_file_system_path ( self , file_system_path ) : for sm in self . state_machines . values ( ) : if sm . file_system_path == file_system_path : return sm
Return a reference to the state machine with respective path if open
40,532
def reset_title ( self , title , notebook_identifier ) : current_title = self . get_top_widget ( ) . get_title ( ) upper_title = current_title . split ( '/' ) [ 0 ] . strip ( ) lower_title = current_title . split ( '/' ) [ 1 ] . strip ( ) if notebook_identifier == 'upper' : new_title = title + ' / ' + lower_title else ...
Triggered whenever a notebook tab is switched in the left bar .
40,533
def add_state ( container_state_m , state_type ) : if container_state_m is None : logger . error ( "Cannot add a state without a parent." ) return False if not isinstance ( container_state_m , StateModel ) or ( isinstance ( container_state_m , StateModel ) and not isinstance ( container_state_m , ContainerStateModel ) ...
Add a state to a container state
40,534
def extract_child_models_of_state ( state_m , new_state_class ) : assert isinstance ( state_m , StateModel ) assert issubclass ( new_state_class , State ) orig_state = state_m . state current_state_is_container = isinstance ( orig_state , ContainerState ) new_state_is_container = issubclass ( new_state_class , Containe...
Retrieve child models of state model
40,535
def create_state_model_for_state ( new_state , meta , state_element_models ) : from rafcon . gui . models . abstract_state import get_state_model_class_for_state state_m_class = get_state_model_class_for_state ( new_state ) new_state_m = state_m_class ( new_state , meta = meta , load_meta_data = False , expected_future...
Create a new state model with the defined properties
40,536
def prepare_state_m_for_insert_as ( state_m_to_insert , previous_state_size ) : if isinstance ( state_m_to_insert , AbstractStateModel ) and not gui_helper_meta_data . model_has_empty_meta ( state_m_to_insert ) : if isinstance ( state_m_to_insert , ContainerStateModel ) : models_dict = { 'state' : state_m_to_insert } f...
Prepares and scales the meta data to fit into actual size of the state .
40,537
def insert_state_as ( target_state_m , state , as_template ) : if not isinstance ( target_state_m , ContainerStateModel ) or not isinstance ( target_state_m . state , ContainerState ) : logger . error ( "States can only be inserted in container states" ) return False state_m = get_state_model_class_for_state ( state ) ...
Add a state into a target state
40,538
def substitute_state_as ( target_state_m , state , as_template , keep_name = False ) : state_m = get_state_model_class_for_state ( state ) ( state ) if as_template : assert isinstance ( state_m , LibraryStateModel ) state_m = state_m . state_copy state_m . state . parent = None if keep_name : state_m . state . name = t...
Substitute a target state with a handed state
40,539
def orify ( e , changed_callback ) : if not hasattr ( e , "callbacks" ) : e . _set = e . set e . _clear = e . clear e . set = lambda : or_set ( e ) e . clear = lambda : or_clear ( e ) e . callbacks = list ( ) e . callbacks . append ( changed_callback )
Add another event to the multi_event
40,540
def create ( * events ) : or_event = threading . Event ( ) def changed ( ) : if any ( [ event . is_set ( ) for event in events ] ) : or_event . set ( ) else : or_event . clear ( ) for e in events : orify ( e , changed ) changed ( ) return or_event
Creates a new multi_event
40,541
def model_changed ( self , model , prop_name , info ) : current_enables = self . _get_config_enables ( ) if not self . _enables == current_enables : filtered_buffer_update_needed = True if all ( self . _enables [ key ] == current_enables [ key ] for key in [ 'VERBOSE' , 'DEBUG' , 'INFO' , 'WARNING' , 'ERROR' ] ) : foll...
React to configuration changes
40,542
def create_path ( path ) : import os if not os . path . exists ( path ) : os . makedirs ( path )
Creates a absolute path in the file system .
40,543
def get_md5_file_hash ( filename ) : import hashlib BLOCKSIZE = 65536 hasher = hashlib . md5 ( ) with open ( filename , 'rb' ) as afile : buf = afile . read ( BLOCKSIZE ) while len ( buf ) > 0 : hasher . update ( buf ) buf = afile . read ( BLOCKSIZE ) return hasher . hexdigest ( )
Calculates the MD5 hash of a file
40,544
def file_needs_update ( target_file , source_file ) : if not os . path . isfile ( target_file ) or get_md5_file_hash ( target_file ) != get_md5_file_hash ( source_file ) : return True return False
Checks if target_file is not existing or differing from source_file
40,545
def copy_file_if_update_required ( source_file , target_file ) : if file_needs_update ( target_file , source_file ) : shutil . copy ( source_file , target_file )
Copies source_file to target_file if latter one in not existing or outdated
40,546
def read_file ( file_path , filename = None ) : file_path = os . path . realpath ( file_path ) if filename : file_path = os . path . join ( file_path , filename ) file_content = None if os . path . isfile ( file_path ) : with open ( file_path , 'r' ) as file_pointer : file_content = file_pointer . read ( ) return file_...
Open file by path and optional filename
40,547
def clean_file_system_paths_from_not_existing_paths ( file_system_paths ) : paths_to_delete = [ ] for path in file_system_paths : if not os . path . exists ( path ) : paths_to_delete . append ( path ) for path in paths_to_delete : file_system_paths . remove ( path )
Cleans list of paths from elements that do not exist
40,548
def update_models ( self , model , name , info ) : if info . method_name in [ "add_input_data_port" , "remove_input_data_port" , "input_data_ports" ] : ( model_list , data_list , model_name , model_class , model_key ) = self . get_model_info ( "input_data_port" ) elif info . method_name in [ "add_output_data_port" , "r...
This method is always triggered when the core state changes
40,549
def _load_income_model ( self ) : self . _add_model ( self . income , self . state . income , IncomeModel )
Create income model from core income
40,550
def _load_outcome_models ( self ) : self . outcomes = [ ] for outcome in self . state . outcomes . values ( ) : self . _add_model ( self . outcomes , outcome , OutcomeModel )
Create outcome models from core outcomes
40,551
def re_initiate_model_list ( self , model_list_or_dict , core_objects_dict , model_name , model_class , model_key ) : if model_name == "income" : if self . income . income != self . state . income : self . _add_model ( self . income , self . state . income , IncomeModel ) return for _ in range ( len ( model_list_or_dic...
Recreate model list
40,552
def _add_model ( self , model_list_or_dict , core_element , model_class , model_key = None , load_meta_data = True ) : found_model = self . _get_future_expected_model ( core_element ) if found_model : found_model . parent = self if model_class is IncomeModel : self . income = found_model if found_model else IncomeModel...
Adds one model for a given core element .
40,553
def add_missing_model ( self , model_list_or_dict , core_elements_dict , model_name , model_class , model_key ) : def core_element_has_model ( core_object ) : for model_or_key in model_list_or_dict : model = model_or_key if model_key is None else model_list_or_dict [ model_or_key ] if core_object is getattr ( model , m...
Adds one missing model
40,554
def remove_additional_model ( self , model_list_or_dict , core_objects_dict , model_name , model_key , destroy = True ) : if model_name == "income" : self . income . prepare_destruction ( ) self . income = None return for model_or_key in model_list_or_dict : model = model_or_key if model_key is None else model_list_or_...
Remove one unnecessary model
40,555
def _get_future_expected_model ( self , core_element ) : for model in self . expected_future_models : if model . core_element is core_element : self . expected_future_models . remove ( model ) return model return None
Hand model for an core element from expected model list and remove the model from this list
40,556
def as_dict ( self , use_preliminary = False ) : config = dict ( ) for key in self . config . keys : if use_preliminary and key in self . preliminary_config : value = self . preliminary_config [ key ] else : value = self . config . get_config_value ( key ) config [ key ] = value return config
Create a copy of the config in form of a dict
40,557
def update_config ( self , config_dict , config_file ) : config_path = path . dirname ( config_file ) self . config . config_file_path = config_file self . config . path = config_path for config_key , config_value in config_dict . items ( ) : if config_value != self . config . get_config_value ( config_key ) : self . s...
Update the content and reference of the config
40,558
def get_current_config_value ( self , config_key , use_preliminary = True , default = None ) : if use_preliminary and config_key in self . preliminary_config : return copy ( self . preliminary_config [ config_key ] ) return copy ( self . config . get_config_value ( config_key , default ) )
Returns the current config value for the given config key
40,559
def set_preliminary_config_value ( self , config_key , config_value ) : if config_value != self . config . get_config_value ( config_key ) : self . preliminary_config [ config_key ] = config_value elif config_key in self . preliminary_config : del self . preliminary_config [ config_key ]
Stores a config value as preliminary new value
40,560
def apply_preliminary_config ( self , save = True ) : state_machine_refresh_required = False for config_key , config_value in self . preliminary_config . items ( ) : self . config . set_config_value ( config_key , config_value ) if config_key in self . config . keys_requiring_state_machine_refresh : state_machine_refre...
Applies the preliminary config to the configuration
40,561
def parent ( self , parent ) : if parent is None : self . _parent = None else : from rafcon . core . states . state import State assert isinstance ( parent , State ) old_parent = self . parent self . _parent = ref ( parent ) valid , message = self . _check_validity ( ) if not valid : if not old_parent : self . _parent ...
Setter for the parent state of the state element
40,562
def _change_property_with_validity_check ( self , property_name , value ) : assert isinstance ( property_name , string_types ) old_value = getattr ( self , property_name ) setattr ( self , property_name , value ) valid , message = self . _check_validity ( ) if not valid : setattr ( self , property_name , old_value ) cl...
Helper method to change a property and reset it if the validity check fails
40,563
def _check_validity ( self ) : from rafcon . core . states . state import State if not self . parent : return True , "no parent" if not isinstance ( self . parent , State ) : return True , "no parental check" return self . parent . check_child_validity ( self )
Checks the validity of the state element s properties
40,564
def register_new_state_machines ( self , model , prop_name , info ) : if info [ 'method_name' ] == '__setitem__' : self . observe_model ( info [ 'args' ] [ 1 ] ) self . logger . info ( NotificationOverview ( info ) ) elif info [ 'method_name' ] == '__delitem__' : pass else : self . logger . warning ( NotificationOvervi...
The method register self as observer newly added StateMachineModels after those were added to the list of state_machines hold by observed StateMachineMangerModel . The method register as observer of observable StateMachineMangerModel . state_machines .
40,565
def observe_root_state_assignments ( self , model , prop_name , info ) : if info [ 'old' ] : self . relieve_model ( info [ 'old' ] ) if info [ 'new' ] : self . observe_model ( info [ 'new' ] ) self . logger . info ( "Exchange observed old root_state model with newly assigned one. sm_id: {}" "" . format ( info [ 'new' ]...
The method relieves observed root_state models and observes newly assigned root_state models .
40,566
def observe_meta_signal_changes ( self , changed_model , prop_name , info ) : self . logger . info ( NotificationOverview ( info ) )
The method prints the structure of all meta_signal - notifications as log - messages .
40,567
def set_dict ( self , new_dict ) : for key , value in new_dict . items ( ) : if isinstance ( value , dict ) : self [ str ( key ) ] = Vividict ( value ) else : self [ str ( key ) ] = value
Sets the dictionary of the Vividict
40,568
def vividict_to_dict ( vividict ) : try : from numpy import ndarray except ImportError : ndarray = dict dictionary = { } def np_to_native ( np_val ) : if isinstance ( np_val , dict ) : for key , value in np_val . items ( ) : np_val [ key ] = np_to_native ( value ) elif isinstance ( np_val , ndarray ) : np_val = np_val ...
Helper method to create Python dicts from arbitrary Vividict objects
40,569
def to_yaml ( cls , dumper , vividict ) : dictionary = cls . vividict_to_dict ( vividict ) node = dumper . represent_mapping ( cls . yaml_tag , dictionary ) return node
Implementation for the abstract method of the base class YAMLObject
40,570
def get_selected_object ( self ) : model , paths = self . tree_view . get_selection ( ) . get_selected_rows ( ) if len ( paths ) == 1 : return self . tree_store . get_iter ( paths [ 0 ] ) , paths [ 0 ] else : return None , paths
Gets the selected object in the treeview
40,571
def on_add ( self , widget , new_dict = False ) : self . semantic_data_counter += 1 treeiter , path = self . get_selected_object ( ) value = dict ( ) if new_dict else "New Value" if treeiter : target_dict_path_as_list = self . tree_store [ path ] [ self . ID_STORAGE_ID ] if not self . tree_store [ path ] [ self . IS_DI...
Adds a new entry to the semantic data of a state . Reloads the tree store .
40,572
def on_remove ( self , widget , data = None ) : treeiter , path = self . get_selected_object ( ) if not treeiter : return dict_path_as_list = self . tree_store [ path ] [ self . ID_STORAGE_ID ] logger . debug ( "Deleting semantic data entry with name {}!" . format ( dict_path_as_list [ - 1 ] ) ) self . model . state . ...
Removes an entry of semantic data of a state .
40,573
def add_items_to_tree_iter ( self , input_dict , treeiter , parent_dict_path = None ) : if parent_dict_path is None : parent_dict_path = [ ] self . get_view_selection ( ) for key , value in sorted ( input_dict . items ( ) ) : element_dict_path = copy . copy ( parent_dict_path ) + [ key ] if isinstance ( value , dict ) ...
Adds all values of the input dict to self . tree_store
40,574
def reload_tree_store_data ( self ) : model , paths = self . tree_view . get_selection ( ) . get_selected_rows ( ) self . tree_store . clear ( ) self . add_items_to_tree_iter ( self . model . state . semantic_data , None ) self . tree_view . expand_all ( ) try : for path in paths : self . tree_view . get_selection ( ) ...
Reloads the data of the tree store
40,575
def copy_action_callback ( self , * event ) : if react_to_event ( self . view , self . tree_view , event ) and self . active_entry_widget is None : _ , dict_paths = self . get_view_selection ( ) selected_data_list = [ ] for dict_path_as_list in dict_paths : value = self . model . state . semantic_data for path_element ...
Add a copy of all selected row dict value pairs to the clipboard
40,576
def paste_action_callback ( self , * event ) : if react_to_event ( self . view , self . tree_view , event ) and self . active_entry_widget is None : _ , dict_paths = self . get_view_selection ( ) selected_data_list = rafcon . gui . clipboard . global_clipboard . get_semantic_dictionary_list ( ) if not dict_paths and no...
Add clipboard key value pairs into all selected sub - dictionary
40,577
def cut_action_callback ( self , * event ) : if react_to_event ( self . view , self . tree_view , event ) and self . active_entry_widget is None : _ , dict_paths = self . get_view_selection ( ) stored_data_list = [ ] for dict_path_as_list in dict_paths : if dict_path_as_list : value = self . model . state . semantic_da...
Add a copy and cut all selected row dict value pairs to the clipboard
40,578
def key_edited ( self , path , new_key_str ) : tree_store_path = self . create_tree_store_path_from_key_string ( path ) if isinstance ( path , string_types ) else path if self . tree_store [ tree_store_path ] [ self . KEY_STORAGE_ID ] == new_key_str : return dict_path = self . tree_store [ tree_store_path ] [ self . ID...
Edits the key of a semantic data entry
40,579
def value_edited ( self , path , new_value_str ) : tree_store_path = self . create_tree_store_path_from_key_string ( path ) if isinstance ( path , string_types ) else path if self . tree_store [ tree_store_path ] [ self . VALUE_STORAGE_ID ] == new_value_str : return dict_path = self . tree_store [ tree_store_path ] [ s...
Adds the value of the semantic data entry
40,580
def store_widget_properties ( self , widget , widget_name ) : if isinstance ( widget , Gtk . Window ) : maximized = bool ( widget . is_maximized ( ) ) self . set_config_value ( '{0}_MAXIMIZED' . format ( widget_name ) , maximized ) if maximized : return size = widget . get_size ( ) self . set_config_value ( '{0}_SIZE' ...
Sets configuration values for widgets
40,581
def update_recently_opened_state_machines_with ( self , state_machine ) : if state_machine . file_system_path : recently_opened_state_machines = self . get_config_value ( 'recently_opened_state_machines' , [ ] ) if state_machine . file_system_path in recently_opened_state_machines : del recently_opened_state_machines [...
Update recently opened list with file system path of handed state machine model
40,582
def extend_recently_opened_by_current_open_state_machines ( self ) : from rafcon . gui . singleton import state_machine_manager_model as state_machine_manager_m for sm_m in state_machine_manager_m . state_machines . values ( ) : self . update_recently_opened_state_machines_with ( sm_m . state_machine )
Update list with all in the state machine manager opened state machines
40,583
def prepare_recently_opened_state_machines_list_for_storage ( self ) : from rafcon . gui . singleton import global_gui_config num = global_gui_config . get_config_value ( 'NUMBER_OF_RECENT_OPENED_STATE_MACHINES_STORED' ) state_machine_paths = self . get_config_value ( 'recently_opened_state_machines' , [ ] ) self . set...
Reduce number of paths in the recent opened state machines to limit from gui config
40,584
def clean_recently_opened_state_machines ( self ) : state_machine_paths = self . get_config_value ( 'recently_opened_state_machines' , [ ] ) filesystem . clean_file_system_paths_from_not_existing_paths ( state_machine_paths ) self . set_config_value ( 'recently_opened_state_machines' , state_machine_paths )
Remove state machines who s file system path does not exist
40,585
def pause ( self ) : if self . state_machine_manager . active_state_machine_id is None : logger . info ( "'Pause' is not a valid action to initiate state machine execution." ) return if self . state_machine_manager . get_active_state_machine ( ) is not None : self . state_machine_manager . get_active_state_machine ( ) ...
Set the execution mode to paused
40,586
def finished_or_stopped ( self ) : return ( self . _status . execution_mode is StateMachineExecutionStatus . STOPPED ) or ( self . _status . execution_mode is StateMachineExecutionStatus . FINISHED )
Condition check on finished or stopped status
40,587
def start ( self , state_machine_id = None , start_state_path = None ) : if not self . finished_or_stopped ( ) : logger . debug ( "Resume execution engine ..." ) self . run_to_states = [ ] if self . state_machine_manager . get_active_state_machine ( ) is not None : self . state_machine_manager . get_active_state_machin...
Start state machine
40,588
def stop ( self ) : logger . debug ( "Stop the state machine execution ..." ) if self . state_machine_manager . get_active_state_machine ( ) is not None : self . state_machine_manager . get_active_state_machine ( ) . root_state . recursively_preempt_states ( ) self . __set_execution_mode_to_stopped ( ) self . _status ....
Set the execution mode to stopped
40,589
def join ( self , timeout = None ) : if self . __wait_for_finishing_thread : if not timeout : while True : self . __wait_for_finishing_thread . join ( 0.5 ) if not self . __wait_for_finishing_thread . isAlive ( ) : break else : self . __wait_for_finishing_thread . join ( timeout ) return not self . __wait_for_finishing...
Blocking wait for the execution to finish
40,590
def _run_active_state_machine ( self ) : self . __running_state_machine = self . state_machine_manager . get_active_state_machine ( ) if not self . __running_state_machine : logger . error ( "The running state machine must not be None" ) self . __running_state_machine . root_state . concurrency_queue = queue . Queue ( ...
Store running state machine and observe its status
40,591
def _wait_for_finishing ( self ) : self . state_machine_running = True self . __running_state_machine . join ( ) self . __set_execution_mode_to_finished ( ) self . state_machine_manager . active_state_machine_id = None plugins . run_on_state_machine_execution_finished ( ) self . state_machine_running = False
Observe running state machine and stop engine if execution has finished
40,592
def backward_step ( self ) : logger . debug ( "Executing backward step ..." ) self . run_to_states = [ ] self . set_execution_mode ( StateMachineExecutionStatus . BACKWARD )
Take a backward step for all active states in the state machine
40,593
def step_mode ( self , state_machine_id = None ) : logger . debug ( "Activate step mode" ) if state_machine_id is not None : self . state_machine_manager . active_state_machine_id = state_machine_id self . run_to_states = [ ] if self . finished_or_stopped ( ) : self . set_execution_mode ( StateMachineExecutionStatus . ...
Set the execution mode to stepping mode . Transitions are only triggered if a new step is triggered
40,594
def run_to_selected_state ( self , path , state_machine_id = None ) : if self . state_machine_manager . get_active_state_machine ( ) is not None : self . state_machine_manager . get_active_state_machine ( ) . root_state . recursively_resume_states ( ) if not self . finished_or_stopped ( ) : logger . debug ( "Resume exe...
Execute the state machine until a specific state . This state won t be executed . This is an asynchronous task
40,595
def _wait_while_in_pause_or_in_step_mode ( self ) : while ( self . _status . execution_mode is StateMachineExecutionStatus . PAUSED ) or ( self . _status . execution_mode is StateMachineExecutionStatus . STEP_MODE ) : try : self . _status . execution_condition_variable . acquire ( ) self . synchronization_counter += 1 ...
Waits as long as the execution_mode is in paused or step_mode
40,596
def _wait_if_required ( self , container_state , next_child_state_to_execute , woke_up_from_pause_or_step_mode ) : wait = True for state_path in copy . deepcopy ( self . run_to_states ) : next_child_state_path = None if next_child_state_to_execute : next_child_state_path = next_child_state_to_execute . get_path ( ) if ...
Calls a blocking wait for the calling thread depending on the execution mode .
40,597
def handle_execution_mode ( self , container_state , next_child_state_to_execute = None ) : self . state_counter_lock . acquire ( ) self . state_counter += 1 self . state_counter_lock . release ( ) woke_up_from_pause_or_step_mode = False if ( self . _status . execution_mode is StateMachineExecutionStatus . PAUSED ) or ...
Checks the current execution status and returns it .
40,598
def execute_state_machine_from_path ( self , state_machine = None , path = None , start_state_path = None , wait_for_execution_finished = True ) : import rafcon . core . singleton from rafcon . core . storage import storage rafcon . core . singleton . library_manager . initialize ( ) if not state_machine : state_machin...
A helper function to start an arbitrary state machine at a given path .
40,599
def set_execution_mode ( self , execution_mode , notify = True ) : if not isinstance ( execution_mode , StateMachineExecutionStatus ) : raise TypeError ( "status must be of type StateMachineExecutionStatus" ) self . _status . execution_mode = execution_mode if notify : self . _status . execution_condition_variable . ac...
An observed setter for the execution mode of the state machine status . This is necessary for the monitoring client to update the local state machine in the same way as the root state machine of the server .