tool

Tool class.

author:
  1. Savolainen (VTT)
date:

19.12.2017

Module Contents

class tool.Tool(toolbox, name, description, tool_template, use_work, x, y)[source]

Bases: project_item.ProjectItem

Tool class.

toolbox

QMainWindow instance

Type:ToolboxUI
name

Object name

Type:str
description

Object description

Type:str
tool_template[source]

Template for this Tool

Type:ToolTemplate
use_work

Execute associated Tool template in work (True) or source directory (False)

Type:bool
x

Initial X coordinate of item icon

Type:int
y

Initial Y coordinate of item icon

Type:int
make_signal_handler_dict(self)[source]

Returns a dictionary of all shared signals and their handlers. This is to enable simpler connecting and disconnecting.

activate(self)[source]

Restore selections and connect signals.

deactivate(self)[source]

Save selections and disconnect signals.

restore_selections(self)[source]

Restore selections into shared widgets when this project item is selected.

save_selections(self)[source]

Save selections in shared widgets for this project item into instance variables.

update_execution_mode(self, checked)[source]

Slot for execute in work radio button toggled signal.

update_tool_template(self, row)[source]

Update Tool template according to selection in the template comboBox.

Parameters:row (int) – Selected row in the comboBox
set_tool_template(self, tool_template)[source]

Sets Tool Template for this Tool. Removes Tool Template if None given as argument.

Parameters:tool_template (ToolTemplate) – Template for this Tool. None removes the template.
update_tool_ui(self)[source]

Update Tool UI to show Tool template details. Used when Tool template is changed. Overrides execution mode (work or source) with the template default.

restore_tool_template(self, tool_template)[source]

Restores the Tool Template of this Tool. Removes Tool Template if None given as argument. Needed in order to override tool template default execution mode (work or source).

Parameters:tool_template (ToolTemplate) – Template for this Tool. None removes the template.
open_results(self, checked=False)[source]

Open output directory in file browser.

get_icon(self)[source]

Returns the graphics item representing this tool in the scene.

edit_tool_template(self)[source]

Open Tool template editor for the Tool template attached to this Tool.

open_tool_template_file(self)[source]

Open Tool template definition file.

open_tool_main_program_file(self)[source]

Open Tool template main program file in an external text edit application.

open_tool_main_directory(self)[source]

Open directory where the Tool template main program is located in file explorer.

tool_template(self)[source]

Returns Tool template.

count_files_and_dirs(self)[source]

Count the number of files and directories in required input files model.

Returns:Tuple containing the number of required files and directories.
create_subdirectories(self)[source]

Iterate items in required input files and check if there are any directories to create. Create found directories directly to ToolInstance base directory.

Returns:Boolean variable depending on success
copy_input_files(self, paths)[source]

Copy input files from given paths to work or source directory, depending on where the Tool template requires them to be.

Parameters:paths (dict) – Key is path to destination file, value is path to source file.
Returns:Boolean variable depending on operation success
copy_optional_input_files(self, paths)[source]

Copy optional input files from given paths to work or source directory, depending on where the Tool template requires them to be.

Parameters:paths (dict) – Key is the optional file name pattern, value is a list of paths to source files.
Returns:Boolean variable depending on operation success
find_output_items(self)[source]

Find output items of this Tool.

Returns:List of Data Store and Data Connection items.
update_instance(self)[source]

Initialize and update instance so that it is ready for processing. This is where Tool type specific initialization happens (whether the tool is GAMS, Python or Julia script).

append_instance_args(self)[source]

Append Tool template command line args into instance args list.

get_instance_args(self)[source]

Return instance args as list.

populate_source_file_model(self, items)[source]

Add required source files (includes) into a model. If items is None or an empty list, model is cleared.

populate_input_file_model(self, items)[source]

Add required Tool input files into a model. If items is None or an empty list, model is cleared.

populate_opt_input_file_model(self, items)[source]

Add optional Tool template files into a model. If items is None or an empty list, model is cleared.

populate_output_file_model(self, items)[source]

Add Tool output files into a model. If items is None or an empty list, model is cleared.

populate_template_model(self, populate)[source]

Add all tool template specs to a single QTreeView. If items is None or an empty list, model is cleared.

Parameters:populate (bool) – False to clear model, True to populate.
update_name_label(self)[source]

Update Tool tab name label. Used only when renaming project items.

open_directory(self, checked=False)[source]

Open file explorer in Tool data directory.

execute(self)[source]

Executes this Tool.

find_input_files(self)[source]

Iterates files in required input files model and looks for them from execution instance.

Returns:Dictionary of paths where required files are found or None if some file was not found.
find_optional_input_files(self)[source]

Tries to find optional input files from previous project items in the DAG. Returns found paths.

Returns:Dictionary of optional input file paths or an empty dictionary if no files found. Key is the optional input item and value is a list of paths that matches the item.
execute_finished(self, return_code)[source]

Tool template execution finished.

Parameters:return_code (int) – Process exit code
stop_execution(self)[source]

Stops executing this Tool.

stop_process(self, checked=False)[source]

Terminate Tool template execution.