vtool.process_manager.process¶
Class Summary
|
This class has functions to work on individual processes in the Process Manager. |
|
keeps data between code runs |
Function Summary
|
|
|
This will try to find the processes in the supplied directory. |
|
|
|
|
|
|
|
This will try to find a a process named process in the directory. |
|
|
Get a default directory to begin in. |
|
|
|
|
source process is an instance of a process that you want to copy target_process is the instance of a process you want to copy to. |
|
source_full_path = source_process.get_path() target_full_path = target_process.get_path() |
|
source_process and target_process need to be instances of the Process class. |
|
source_process and target_process need to be instances of the Process class. |
|
|
|
|
|
|
|
|
|
|
|
Backs up the process at the path to the process/.backup folder If backup directory given, backs up there. |
|
|
|
|
|
|
|
- decorator_undo_chunk(function)¶
- find_processes(directory=None, return_also_non_process_list=False, stop_at_one=False)¶
This will try to find the processes in the supplied directory. If no directory supplied, it will search the current working directory.
- Parameters
directory (str) – The directory to search for processes.
- Returns
The procceses in the directory.
- Return type
list
- is_interesting_folder(folder_name, directory)¶
- is_process(directory)¶
- is_process_enabled(directory)¶
- get_unused_process_name(directory=None, name=None)¶
This will try to find a a process named process in the directory.
It will increment the name to process1 and beyond until it finds a unique name. If no directory supplied, it will search the current working directory.
- Parameters
directory (str) – Direcotry to search for processes.
name (str) – name to give the process.
- Returns
The unique process name.
- Return type
str
- decorator_process_run_script(function)¶
- class Process(name=None)¶
This class has functions to work on individual processes in the Process Manager.
- description = 'process'¶
- data_folder_name = '.data'¶
- code_folder_name = '.code'¶
- backup_folder_name = '.backup'¶
- process_data_filename = 'manifest.data'¶
- enable_filename = '.enable'¶
- set_directory(directory)¶
- Parameters
directory (str) – Directory path to the process that should be created or where an existing process lives.
- load(name)¶
Loads the named process into the instance.
- Parameters
name (str) – Name of a process found in the directory.
- Returns
None
- set_external_code_library(directory)¶
- Parameters
directory (str,list) – Directory or list of directories where code can be sourced from. This makes it more convenient when writing scripts in a process.
- is_process()¶
- Returns
Check to see if the initialized process is valid.
- Return type
bool
- set_enabled(bool_value)¶
- is_enabled()¶
- has_sub_parts()¶
- get_non_process_parts()¶
- get_path()¶
- Returns
The full path to the process folder. If the process hasn’t been created yet, this will return the directory set in set_directory.
- Return type
str
- get_name()¶
- Returns
The name of the process.
- Return type
str
- get_basename()¶
- Returns
The name of the process. If no name return basename of directory.
- Return type
str
- get_relative_process(relative_path)¶
- Parameters
relative_path (str) – The path to a relative process.
- Returns
An instance of a process at the relative path.
If a name with no backslash is supplied, this will return any matching process parented directly under the current process.
A relative path like, ‘../face’ or ‘../../other_character’ can be used.
Every ‘..’ signifies a folder above the current process.
- Return type
- get_sub_process_count()¶
- Returns
The number of sub processes under the current.
- Return type
int
- get_sub_processes()¶
- Returns
The process names found directly under the current process.
- Return type
list
- get_sub_process(part_name)¶
- Parameters
part_name (str) – The name of a child process.
- Returns
A sub process if there is one that matches part_name.
- Return type
- get_sub_process_by_index(index)¶
- get_parent_process()¶
- get_empty_process(path=None)¶
- get_backup_path(directory=None)¶
- backup(comment='Backup', directory=None)¶
- is_data_folder(name, sub_folder=None)¶
- Parameters
name (str) – The name of a data folder in the process.
- Returns
True if the supplied name string matches the name of the a data folder in the current process.
- Return type
bool
- get_data_path(in_folder=True)¶
- Returns
The path to the data folder for this process.
- Return type
str
- get_data_folder(name, sub_folder=None)¶
- Parameters
name (str) – The name of a data folder in the process.
- Returns
The path to the data folder with the same name if it exists.
- Return type
str
- get_data_sub_path(name)¶
Get that path where sub folders live
- get_data_type(name)¶
- Parameters
name (str) – The name of a data folder in the process.
- Returns
The name of the data type of the data folder with the same name if it exists.
- Return type
str
- get_data_file_or_folder(name, sub_folder_name=None)¶
Data is either saved to a top file or a top folder. This is the main data saved under the data folder. This file or folder is used for versioning. This will return the file or folder that gets versioned.
- get_data_version_count(data_name)¶
- get_data_versions(data_name)¶
- get_data_version_paths(data_name)¶
- get_data_version_path(data_name, version_number)¶
- get_data_folders()¶
- Returns
A list of data folder names found in the current process.
- Return type
list
- get_data_instance(name, sub_folder=None)¶
- Parameters
name (str) – The name of a data folder in the process.
- Returns
An instance of the data type class for data with the specified name in the current process.
This gives access to the data functions like import_data found in the data type class.
- Return type
- create_data(name, data_type, sub_folder=None)¶
- Parameters
name (str) – The name of a data folder in the process.
data_type (str) – A string with the name of the data type of the data in the process.
- Returns
The path to the new data folder.
- Return type
str
- has_sub_folder(data_name, sub_folder_name)¶
Has a sub folder of name.
- create_sub_folder(data_name, sub_folder_name)¶
- get_data_sub_folder_names(data_name)¶
- get_data_current_sub_folder(name)¶
Get the currently set sub folder
- get_data_current_sub_folder_and_type(name)¶
Get the currently set sub folder and its data type
- import_data(name, sub_folder=None)¶
Convenience function which will run the import_data function found on the data_type instance for the specified data folder.
- Parameters
name (str) – The name of a data folder in the process.
- Returns
None
- open_data(name, sub_folder=None)¶
- reference_data(name, sub_folder=None)¶
- save_data(name, comment='', sub_folder=None)¶
Convenience function that tries to run the save function found on the data_type instance for the specified data folder. Not all data type instances have a save function.
- Parameters
name (str) – The name of a data folder in the process.
- Returns
None
- export_data(name, comment='', sub_folder=None, list_to_export=[])¶
Convenience function that tries to run the export function found on the data_type instance for the specified data folder. Not all data type instances have a save function.
- Parameters
name (str) – The name of a data folder in the process.
- Returns
None
- set_data_parent_folder(folder_name)¶
Within the data path, sets folder_name as the parent folder to the data
- remove_data_parent_folder()¶
- rename_data(old_name, new_name)¶
Renames the data folder specified with old_name to the new_name.
- Parameters
old_name (str) – The current name of the data.
new_name (str) – The new name for the data.
- Returns
The new path to the data if rename was successful.
- Return type
str
- delete_data(name, sub_folder=None)¶
Deletes the specified data folder from the file system.
- Parameters
name (str) – The name of a data folder in the process.
- Returns
None
- copy_sub_folder_to_data(sub_folder_name, data_name)¶
- copy_data_to_sub_folder(data_name, sub_folder_name)¶
- remove_data_versions(name, sub_folder=None, keep=1)¶
- cache_data_type_read(name)¶
- delete_cache_data_type_read(name)¶
- is_code_folder(name)¶
- Parameters
name (str) – The name of a code folder in the process.
- Returns
If the supplied name string matches the name of a code folder in the current process.
- Return type
bool
- get_code_path()¶
- Returns
The path to the code folder for this process.
- Return type
str
- get_code_folder(name)¶
- Parameters
name (str) – The name of a code folder in the process.
- Returns
A path to the code folder with the supplied name string if it exists.
- Return type
str
- get_code_folders(code_name=None)¶
- Returns
A list of code folder names found in the current process.
- Return type
list
- get_top_level_code_folders()¶
- get_code_names()¶
- get_code_children(code_name)¶
- get_code_type(name)¶
- Parameters
name (str) – The name of a code folder in the process.
- Returns
The code type name of the code folder with the supplied name if the code folder exists. Otherwise return None. Right now only python code type is used by the Process Manager.
- Return type
str
- get_code_files(basename=False, fast_with_less_checking=False)¶
- Parameters
basename (bool) – Wether to return the full path or just the name of the file.
- Returns
The path to the code files found in the code folder for the current process. If basename is True, only return the file names without the path.
- Return type
list
- get_code_file(name, basename=False)¶
- Parameters
name (str) – The name of a code folder in the process.
basename (bool) – Wether to return the full path or just the name of the file.
- Returns
The path to the code file with the specified name in the current process.
- Return type
str
- get_first_matching_code(name)¶
- get_code_name_from_path(code_path)¶
- get_code_module(name)¶
- Returns
The module instance bool: If the module sourced properly or not str: The status of the source. Error messages etc.
- Return type
module
- create_code(name, data_type='script.python', inc_name=False, import_data=None)¶
Create a new code folder with the specified name and data_type.
- Parameters
name (str) – The name of the code to create.
data_type (str) – Usually ‘script.python’.
inc_name (bool) – Wether or not to increment the name.
import_data (str) – The name of data in the process.
data. (Lines will be added to the code file to import the) –
- Returns
Filename
- Return type
str
- move_code(old_name, new_name)¶
- rename_code(old_name, new_name)¶
Renames the code folder specified with old_name to the new_name.
- Parameters
old_name (str) – The current name of the code.
new_name (str) – The new name for the code.
- Returns
The new path to the code if rename was successful.
- Return type
str
- delete_code(name)¶
Deletes the specified data folder from the file system.
- Parameters
name (str) – The name of a data folder in the process.
- Returns
None
- remove_code_versions(code_name, keep=1)¶
- get_setting_names()¶
- get_setting_file(name)¶
- get_settings_file()¶
- get_settings_inst()¶
- set_setting(name, value)¶
- get_setting(name)¶
- get_control(description, side)¶
- has_options()¶
- add_option(name, value, group=None, option_type=None)¶
- set_option(name, value, group=None)¶
- get_unformatted_option(name, group=None)¶
- set_option_index(index, name, group=None)¶
- get_option(name, group=None)¶
Get an option by name and group
- get_option_match(name, return_first=True)¶
Try to find a matching option in all the options
- has_option(name, group=None)¶
- get_options()¶
- get_option_name_at_index(index)¶
- get_option_file()¶
- clear_options()¶
- save_default_option_history()¶
- load_default_option_history()¶
- get_option_history()¶
- get_manifest(manifest_file=None)¶
- Returns
(list, list) Two lists, scripts and states. The scripts list contains the name of scripts in the manifest. States contains the enabled/disabled state of the script.
- Return type
tuple
- get_manifest_dict(manifest_file=None)¶
- Returns
name of code : state
- Return type
dict
- get_manifest_folder()¶
- Returns
The path to the manifest folder.
- Return type
str
- get_manifest_file()¶
- Returns
The path to the manifest file.
- Return type
str
- get_manifest_scripts(basename=True, fast_with_less_checks=False)¶
- Parameters
basename (bool) – Wether to return the full path or just the name of the file.
- Returns
The code files named in the manifest.
- Return type
list
- is_in_manifest(entry)¶
- get_manifest_history()¶
- set_manifest(scripts, states=[], append=False)¶
This will tell the manifest what scripts to list. Scripts is a list of python files that need to correspond with code data.
- Parameters
scripts (list) – List of scripts to add to the manifest.
states (list) – List that of states for that corresponds to the scripts list.
append (bool) – Wether to add the scripts to the end of the manifest or replace it.
- has_script(script_name)¶
- get_script_parent(script_name)¶
- get_previous_script(script_name)¶
- insert_manifest_below(script_name, previous_script_name, state=False)¶
- get_script_state(script_name)¶
- set_script_state(script_name, bool_value)¶
- sync_manifest()¶
Sync the manifest with whats on disk.
- add_part(name)¶
- Parameters
name (str) – Name for a new process.
- Returns
Instnace of the added part.
- Return type
- create()¶
Create the process.
- Retrun
(str): Path to the process.
- delete()¶
Delete the process.
- Returns
None
- rename(new_name)¶
Rename the process.
- Parameters
new_name (str) – New name for the process.
- Returns
Wether or not the process was renamed properly.
- Return type
bool
- run_script(script, hard_error=True, settings=None, return_status=False)¶
Run a script in the process.
- Parameters
script (str) – Name of a code in the process.
hard_error (bool) – Wether to error hard when errors encountered, or to just pass an error string.
- Returns
The status from running the script. This includes error messages.
- Return type
str
- run_option_script(name, group=None, hard_error=True)¶
- run_code_snippet(code_snippet_string, hard_error=True)¶
- run_script_group(script, clear_selection=True, hard_error=True)¶
This runs the script and all of its children/grandchildren.
- run(start_new=False)¶
Run all the scripts in the manifest, respecting their on/off state.
- Returns
None
- set_runtime_value(name, value)¶
This stores data to run between scripts.
- Parameters
name (str) – The name of the script.
value – Can be many different types including str, list, tuple, float, int, etc.
- Returns
None
- get_runtime_value(name)¶
Get the value stored with set_runtime_value.
- Parameters
name (str) – The name given to the runtime value in set_runtime_value.
- Returns
The value stored in set_runtime_value.
- get_runtime_value_keys()¶
Get the runtime value dictionary keys. Every time a value is set with set_runtime_value, and dictionary entry is made.
- Returns
keys in runtime value dictionary.
- Return type
list
- set_data_override(process_inst)¶
- get_data_override()¶
- run_batch()¶
- run_deadline()¶
- reset_runtime()¶
- class Put¶
keeps data between code runs
- set(name, value)¶
- get_attribute_names()¶
- clear() None. Remove all items from D.¶
- copy() a shallow copy of D¶
- fromkeys(value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items() a set-like object providing a view on D's items¶
- keys() a set-like object providing a view on D's keys¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If key is not found, d is returned if given, otherwise KeyError is raised
- popitem() (k, v), remove and return some (key, value) pair as a¶
2-tuple; but raise KeyError if D is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from dict/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values() an object providing a view on D's values¶
- get_default_directory()¶
Get a default directory to begin in. The directory is different if running from inside Maya.
- Returns
Path to the default directory.
- Return type
str
- copy(source_file_or_folder, target_file_or_folder, description='')¶
- copy_process(source_process, target_process=None)¶
source process is an instance of a process that you want to copy target_process is the instance of a process you want to copy to. If no target_process is specified, the target process will be set to the directory where the source process is located automatically. If there is already a process named the same in the target process, the name will be incremented. If you need to give the copy a specific name, you should rename it after copy.
- Parameters
source_process (str) – The instance of a process.
target_process (str) – The instance of a process. If None give, duplicate the source_process.
- copy_process_into(source_process, target_process, merge_sub_folders=False)¶
source_full_path = source_process.get_path() target_full_path = target_process.get_path()
if source_full_path == target_full_path:
return
- copy_process_data(source_process, target_process, data_name, replace=False, sub_folder=None)¶
source_process and target_process need to be instances of the Process class. The instances should be set to the directory and process name desired to work with. data_name specifies the name of the data folder to copy. If replace the existing data with the same name will be deleted and replaced by the copy.
- Parameters
source_process (str) – The instance of a process.
target_process (str) – The instance of a process.
data_name (str) – The name of the data to copy.
replace (bool) – Wether to replace the data in the target process or just version up.
sub_folder (str) – The name of the sub folder to copy
- copy_process_code(source_process, target_process, code_name, replace=False)¶
source_process and target_process need to be instances of the Process class. The instances should be set to the directory and process name desired to work with. code_name specifies the name of the code folder to copy. If replace the existing code with the same name will be deleted and replaced by the copy.
- Parameters
source_process (str) – The instance of a process.
target_process (str) – The instance of a process.
code_name (str) – The name of the code to copy.
replace (bool) – Wether to replace the code in the target process or just version up.
- copy_process_setting(source_process, target_process, setting_name)¶
- get_vetala_settings_inst()¶
- initialize_project_settings(project_directory, settings_inst=None)¶
- get_project_setting(name, project_directory, settings_inst=None)¶
- set_project_setting(name, value, project_directory, settings_inst=None)¶
- get_custom_backup_directory(process_directory)¶
- backup_process(process_path=None, comment='Backup', backup_directory=None)¶
Backs up the process at the path to the process/.backup folder If backup directory given, backs up there.
- get_process_builtins(process)¶
- reset_process_builtins(process, custom_builtins={})¶
- setup_process_builtins(process, custom_builtins={})¶
- run_deadline(process_directory, name, parent_jobs=[], batch_name=None)¶