sas package

Submodules

sas.inspectasset module

This module contains functions related to inspecting Houdini digital assets and determining which other assets they depend on. It also has functions to extract icons from assets and embed them into them.

sas.inspectasset.extract_node_type_category_name(node_type_name)
sas.inspectasset.find_node_type(otl_file, node_type_name)

Look in an OTL file for the given hou.NodeType and return it. Returns None if the OTL file does not contain a node type with that name.

sas.inspectasset.full_node_type_name_from_definition(definition)

Given an HDADefinition, return its full node type name (i.e. in Category/name) form.

sas.inspectasset.get_dependency_info_for_node(node, skip_nested_namespaces=True)

Search the given asset instance and return information about itself and the node types it uses, in the same format as get_otl_file_info.

The value for “missing” in the returned dictionary is always an empty list.

sas.inspectasset.get_otl_file_info(otl_file, skip_nested_namespaces=True)

Searches an OTL file and return JSON containing dependencies from a node type to other node types defined in the OTL.

skip_nested_namespaces: When True, node types that are embedded inside
other node types will be ignored (unless there are missing dependencies).

For all the node types defined in the given OTL file, information is put in a single block of JSON. For example, this function might return the following:

{
“contents”: {
“car”: {
“descriptive_name”: “Car”, “category_name”: “Object”, “depends_on”: [“wheel”] “otl_file”: “car_and_wheel.otl”, “icon_type”: None, “is_nested”: False, “houdini_version”: “12.5.427”

}, “wheel”: {

“descriptive_name”: “Wheel”, “category_name”: “Object”, “depends_on”: [] “otl_file”: “car_and_wheel.otl”, “icon_type”: None, “is_nested”: False, “houdini_version”: “12.5.427”

},

}, “missing”: []

}

if “wheel” and “car” are in the OTL file and “car” depends on “wheel”. Or, it might return:

{
“contents”: {
“car”: {
“descriptive_name”: “Car”, “category_name”: “Object”, “depends_on”: [“wheel”] “otl_file”: “car.otl”, “icon_type”: None, “is_nested”: False, “houdini_version”: “12.5.427”

},

}, “missing”: [[“Object”, “wheel”]]

}

if “wheel” is not in the OTL file.

Node types built into Houdini are not included in the output. The result dependency dictionary is not expanded: if A, B, and C are node types, A uses B, and B uses C, the dependencies will be {“A”: [“B”], “B”: [“C”]}, not {“A”: [“B”, “C”]}.

Note that “icon_type” is one of “png”, “svg”, or None.

sas.inspectasset.icon_type(node_type)

Return the type of icon file that can be extracted from a node type (either “png” or “svg”), or None if the node type does not contain an embedded icon.

Icon references in Houdini can either be the special icon section names or they can be normal opdef references. If it’s a normal reference to a non-SVG file then it must be to a bitmap image, and we’ll convert that to a PNG.

sas.inspectasset.is_asset_type(node_type)

Return whether the given node type is a user-defined asset.

sas.inspectasset.is_namespaced_node_type(node_type)
sas.inspectasset.is_nested_node_type(node_type)

Return whether this node type is nested inside another node type.

Note that instances of nested node types can only be created inside instances of the containing node type.

sas.inspectasset.is_nested_node_type_from_definition(definition)

Given a defintiion, return whether this node type is nested inside another node type.

sas.inspectasset.node_type_name_with_category(node_type_name, category)
sas.inspectasset.node_type_name_with_vendor(node_type_name, vendor)

Given a node type name (which may or may not include the category), return a new node type name that adds/changes the vendor (author) prefix.

sas.inspectasset.node_type_name_without_category(node_type_name)

Given a node type name that may or may not include the node type category, return one without any node type category.

For example, if you pass in “Object/geo” this function returns “geo”. If you pass in “SideFX::Object/geo”, it returns “SideFX::geo”.

sas.inspectasset.read_icon_data(image_file)

Read the icon data from a image file on disk (SVG or raster data), convert it into the appropriate format needed by Houdini, and return an (icon_section_name, image_data) tuple.

The icon_section_name is where Houdini will store the image if it’s put into an asset definition, and identifies whether the data is svg or raster data.

sas.inspectasset.save_icon(node_type, output_file, icon_dimensions)

Given a node type for an asset that has an icon file, write the icon to the given output file.

sas.inspectasset.scoping_node_type_name(node_type)
sas.inspectasset.scoping_node_type_name_from_name(node_type_name)
sas.inspectasset.set_icon(node_type, icon_section_name, icon_data)

Set the icon for an asset to the given raw icon data (.svg or .pic) format, storing it in the given section name.

sas.localassets module

class sas.localassets.CurrentUser
name = ''
class sas.localassets.SessionData(server, session_key)

Bases: hutil.api.ClientSessionData

class sas.localassets.StoreAPI(session_data)

Bases: hutil.api.ClientAPIConnection

class sas.localassets.WebResponderAPI(port)

Bases: object

This class forms the API that the URL scheme handler uses to control Houdini.

begin_upload_with_credentials(session_key)
invoke_callback_to_return_cached_session_key()
return_session_key(session_key, username)
show_asset_in_running_session(node_type_category_name, node_type_name, current_user=None)
sas.localassets.asset_store_dir()
sas.localassets.begin_upload_with_credentials(*args, **kwargs)

When uploading from Houdini, the user first needs to log into the web site, and then the running Houdini is told to upload the asset via the websreponder thread. The webresponder thread calls this function, passing in the session key to prove that the user is logged in.

sas.localassets.begin_uploading_asset(node, server=None)
sas.localassets.begin_uploading_dependent_asset(uploading_node, session_key, containing_node=None, store_server=None)

This function is called both after the user logs in to initiate the upload process (i.e. from begin_upload_with_credentials) (in which case containing_node won’t be passed in), when uploading dependent assets from the asset dependencies dialog, and when finally uploading the containing asset after completing uploading dependencies (containing_node will be None in that case too).

sas.localassets.check_for_asset_updates(*args, **kwargs)
sas.localassets.check_for_shelf_tool_assets(*args, **kwargs)
sas.localassets.check_for_shelf_tool_assets_wrapper()
sas.localassets.create_namespaced_otl(otl_file, author_prefix, new_node_type_name=None, new_suffix='-with_author', dependencies_must_be_embedded=True, other_old_to_new_node_types=None)

Given an otl file with one top-level asset, copy it into an otl file with the given suffix and add/change an author prefix to the namespace.

Returns a (node, old_node_type) tuple, where node is the instance of the new namespaced node type.

See _install_otl_and_get_node_type for information about the dependencies_must_be_added parameter.

sas.localassets.deferred_decorator(callback_returning_decorator)

This decorator defers another decorator from being called until the decorated function is actually called.

sas.localassets.ensure_webresponder_server_is_running()
sas.localassets.file_name_with_suffix(original_file, new_suffix)
sas.localassets.get_session_key(callback, server=None, username=None, force_login=False)
sas.localassets.get_store_logged_in_user_name(session_key)
sas.localassets.get_sync_information(session_key)
sas.localassets.install_or_update_asset_from_houdinis_browser(server, session_key, license_number)

This function is called when an asset is launched from inside houdini’s browser.

sas.localassets.install_or_update_asset_from_license_number(session_data, license_number)

This function is called when the URL scheme handler is told to install an asset.

sas.localassets.install_url_handler()
sas.localassets.prepare_node_for_uploading(node, author_prefix, store_server=None)

Given an instance of an asset, prepare it for uploading to the store by: - making sure the node type and its dependencies are in their own otl files - ensuring the asset contains the author’s prefix in the namespaced node

type name

Returns the node (which may have had its type changed) on success, and None if the user cancelled the process.

sas.localassets.show_asset_for_node_type(node_type_category_name, node_type_name)
sas.localassets.show_asset_in_newly_launched_session(node_type_category_name, node_type_name, current_user)

Now that a new Houdini session has been started, install the asset and create an instance of it.

This function is invoked from the script that starts a new instance of Houdini.

sas.localassets.show_asset_in_running_session(*args, **kwargs)

Present a prompt to the user to allow them to decide whether or not to open the downloaded asset in their current houdini session, or to open a new session.

If the asset does not have an example hip file, open the asset browser pane in the session and create an instance of the asset. Otherwise, merge the example hip file into the current hip file.

sas.localassets.update_asset_browser()
sas.localassets.update_existing_asset_browsers()
sas.localassets.update_installed_asset_from_license_number(server, session_key, license_number)
sas.localassets.upload_asset(otl_file, session_key, server=None)

This function is called by OPUI_UploadAssetDialog to actually upload the asset to the store using the web API.

sas.localassets.upload_asset_inside_houdini_browser(session_key, server, author_prefix)

This function is called when selecting an asset to upload inside Houdini’s browser.

sas.localassets.upload_screenshot(server, session_key, unique_name, upload_id, x, y)

Upload a screenshot from Houdini’s browser, during the upload process.

sas.webresponder module

sas.webresponder.connect_to_any_server(timeout=5)

From a client, try multiple ports to find a running instance of Houdini.

Returns an hjsonrpc.ServiceProxy object on success, or None if no connection could be made.

sas.webresponder.connect_to_server(port, timeout=5)

From a client, connect to a server on a specific port.

sas.webresponder.port_range()

Return the range of possible port numbers that instances of Houdini may be listening on.

sas.webresponder.start_server(api_class)

Start a server from inside Houdini, finding an available port, and process requests made to it from a new thread.

api_class: An class with methods decorated with hjsonrpc.rpcMethod. This function will create an instance of the class, passing in the port number.

Returns an instance of the api_class, or None if all ports are in use.

Module contents