|
SGO Mistika: Python Extension
|
The Cpython class provides functionality to manage Python Nodes. More...
Public Slots | |
| Cconnector * | addConnector (const QString &name, Cconnector::connectorType type, Cconnector::connectorMode mode) |
| Adds a conector called name of type type and mode mode. | |
| void | addProperty (const QString &name, QVariant value=QVariant()) |
| Adds a property called name with default value value. | |
| void | addEncryptedProperty (const QString &name, QVariant value=QVariant()) |
| Adds an encrypted property to the node. | |
| void | setSupportedTypes (nodeType_t types) |
| Sets the node types that this Python node supports. | |
| QString | getDropToProperty () const |
| Returns the name of the property that will accept the drop file actions an empty string disables the drop functionality. | |
| void | setDropToProperty (const QString &dropProperty) |
| Assigns the name of the property that will accept the drop file actions an empty value means no property is unassigned . | |
| int | getDropSupportedTypes () const |
| Returns the file types supported during the drop file actions. | |
| QStringList | getDropSupportedFileMasks () const |
| Returns the list of File Masks supported by the node An empty list accept all Files By default the list is empty. | |
| void | setDropSupportedTypes (int types) |
| Set the File Types supported . | |
| void | setDropSupportedFileMasks (const QStringList &dropSupportedFileMasks) |
| Set the list of File Masks supported by the node example: setDropSupportedFileMasks(["*.mov", "*.mp4"]). | |
| void | setAcceptConnectors (bool enabled, const QString &name, const QString label=QString()) |
| Enables/disables the ability to create connectors with drag and drop. | |
| void | rebuild () |
| Forces a call to the node init function. | |
| void | addActionToContextMenu (const QString &actionName) |
| Adds an action to the Node Context Menu If there Action already exists, this function does nothing. | |
| void | removeActionFromContextMenu (const QString &actionName) |
| Removes an action to the Node Context Menu If there Action does not exist, this function does nothing. | |
| void | setClassName (const QString &name) |
| sets the Class name to display in the Finder The class ID will be the valid variable name related with this string (Removing space and other unsupported variable name characters) If this function is not called, the file Name will be used If called, it must be called from the init funcion. | |
| bool | addTemplateFromFile (const QString &filePath, const QString &property) |
| adds a template manager for a property. | |
| CpythonStore * | getStore () const |
| gets the node attribute's Store This repository can be used to store information inside the node That information is persistant along multiple executions. So It is perfect to cache data that needs to be calculated only once. It can also be used to pass information between node functions (from init to process, or any other combination) | |
| CexternalAppNodeLink * | createExternalApp () |
| returns the new CexternalAppNodeLink instance This link can be used to execute external applications from the python node using all the CexternalAppNodeLink functionality It is important to delete this instance when it is no longer needed by calling the deleteLater method | |
| CexecutionQueue * | createExecutionQueue (int maxThreads) const |
| returns the new CexecutionQueue instance This link can be used to Queue external applications to be multithreaded It is important to delete this instance when it is no longer needed by calling the deleteLater method | |
| bool | addPermanentCritical (const QString &id, const QString &description, const QString &group=QString()) |
| Add a permanent critical error that will be reported when evaluating the isReady status. Permanent errors are stored and remain active until removed with clearAllPermanentErrors(), clearPermanentErrorById(), or clearPermanentErrorsByGroup(). | |
| bool | addPermanentError (const QString &id, const QString &description, const QString &group=QString()) |
| Add a permanent error that will be reported when evaluating the isReady status. Permanent errors are stored and remain active until removed with clearAllPermanentErrors(), clearPermanentErrorById(), or clearPermanentErrorsByGroup(). | |
| void | clearPermanentErrors () |
| Delete all permanent errors stored in the node. | |
| void | deletePermanentErrorById (const QString &id) |
| Delete one permanent error with the specified id. | |
| void | deletePermanentErrorsByGroup (const QString &group) |
| Delete all permanent errors included in the specified errors group. | |
| Public Slots inherited from CbaseItem | |
| QList< Cconnector * > | getConnectors (Cconnector::connectorSpecialType special=Cconnector::CONNECTOR_SPECIALTYPE_NORMAL) const |
| Returns the list of connectors available. | |
| Cconnector * | getFirstConnectorByName (const QString &name) const |
| Returns the first connector found with a given name. | |
| Cconnector * | getFirstConnectorByType (Cconnector::connectorType type, const QString &name) const |
| Returns the first connector found with a given type and name. | |
| QList< Cconnector * > | getConnectorsByName (const QString &name=QString()) const |
| Returns the list of all connectors found with a given name This function returns a list of all connectors that match the specified name. If the name ends with '', it will match connectors with names that start with the prefix followed by a space and optional digits. | |
| QList< Cconnector * > | getConnectorsByName (const QRegularExpression &rx) const |
| Returns the list of all connectors matching the given Regular Expression This function returns a list of all connectors that match the specified regular expression. | |
| QList< Cconnector * > | getConnectorsByType (Cconnector::connectorType type, const QString &name=QString()) const |
| Returns the list of all connectors of the given type and matching the given name This function returns a list of all connectors that match both the specified type and name. If the name is empty, all connectors of the given type and special type will be returned. | |
| QList< Cconnector * > | getConnectorsByType (Cconnector::connectorType type, Cconnector::connectorSpecialType special, const QString &name=QString()) const |
| Returns the list of all connectors of the given type and matching the given name. | |
| QList< Cconnector * > | getConnectorsByType (Cconnector::connectorType type, const QRegularExpression &rx) const |
| Returns the list of all connectors of the given type and matching the given regular expression. | |
| QList< Cconnector * > | getConnectorsByType (Cconnector::connectorType type, Cconnector::connectorSpecialType special, const QRegularExpression &rx) const |
| Returns the list of all connectors of the given type, special type and matching the given regular expression. | |
| QList< Cconnector * > | getVisibleConnectorsByType (Cconnector::connectorType type, const QString &name=QString(), Cconnector::connectorSpecialType specialType=Cconnector::CONNECTOR_SPECIALTYPE_ALL) const |
| This function returns a list of all visible connectors that match the specified type, name, and special type. Connectors are filtered to only include those that are visible. | |
| bool | critical (const QString &identifier, const QString &description, const QString &property=QString()) const |
| Reports a critical error. | |
| bool | error (const QString &identifier, const QString &description, const QString &property=QString()) const |
| Reports an error. | |
| bool | warning (const QString &identifier, const QString &description, const QString &property=QString()) const |
| Reports a warning message. | |
| bool | info (const QString &identifier, const QString &description, const QString &property=QString()) const |
| Reports an information message. | |
| QMap< QString, QVariant > | getAllProperties () const |
| Returns all the available Properties in the node. | |
| void | setPropertyVisible (const QString &propName, bool visible) |
| CbaseItem::setPropertyVisible. | |
| CnameConvention | getNameConvention () const |
| Returns the node name convention. | |
| Cworkflow * | getWorkflow () const |
| Returns the workflow owner of the item. | |
| CbaseItem * | getRegisteredItem (const QString &id) const |
| Gets a pointer to the registered version of a base Item This is a private function. do not use it unless you know what you are doing. the CbaseItem returned does not exist in any workflow instance, and it should be used carefully to access static funcctions only. | |
| QList< CbaseItem * > | getAllRegisteredNodes () const |
| Gets a list of pointers to all the registered nodes Function added in V10.12 This Function is equivalent to Workflows::getAllRegisteredNodes. | |
| void | dropConnector (Cconnector *connector) const |
| emulates the behavior of droping a connector into the node | |
| CuniversalPath | composeDstFilePath (const QString &dstFilePath, const CuniversalPath &input, bool isSequence, int minPadFromInputs=0) const |
| CbaseItem::composeDstFilePath. | |
| void | setPropertiesFromJson (const QJsonObject &json) |
| set object properties from a json structure | |
| void | addRecentItem (const QString &id, const QVariant &value) |
| Adds an item to the list of recent Items If this list is not empty, a submenu "recent files" will appear into the node contextual menu with links to the added values. | |
| void | setPropertiesFromUP (const CuniversalPath &up) |
| set object properties from a json structure comming in the privateData of one UniversalPath | |
| int | getStatus () const |
| Returns the latest registered status for the node STATUS_UNKNOWN=-1, Unknown Status STATUS_DISCONNECTED=0, The Item is disconnected STATUS_OPTIONAL=1, The Item is optional (It does not need to be connected) STATUS_CONNECTED=2, The Item is connected STATUS_READY=3, The Item is ready to be processed STATUS_PROCESSING=4, The Item is being processed STATUS_FAILED=5, The process failed STATUS_DONE=6 The process successfuly finished . | |
| QString | getStatusName (int status) const |
| CbaseItem::getStatusName. | |
| QSet< QString > | getTags () |
| getTags | |
| void | setTags (const QSet< QString > &newTags) |
| setTags | |
| bool | addTag (const QString &tag) |
| addTag | |
| bool | removeTag (const QString &tag) |
| removeTag | |
Public Member Functions | |
| virtual void | workflowFinished (bool success) override |
| If defined in Python, This function is called when the workflow finishes the execution. | |
| virtual QVariant | evaluate (const QString &exp) const override |
| Allows the node to evaluate python code. | |
| Public Member Functions inherited from CbaseItem | |
| Cworkflow * | findWorkflow () const |
| Finds the workflow associated with this item. | |
| CnameConvention | getDefaultNameConvention () const |
| Gets the default name convention for this item. | |
| CuniversalPath | fixUrlPathSimple (const QString &filePath, bool isSequence, bool filePathWithFrame=false) const |
| Fixes a URL path using simple path fixing. | |
| virtual CuniversalPath | fixUrlPath (const QString &filePath) const |
| Fixes a URL path This virtual function is used to complete the filePath when needed based on any external input such as connectors, etc. (adding the input fileName if local is empty, etc. The parent implementation (CfileHolder) returns the filePath as it is. | |
| bool | getFixChangesType () const |
Additional Inherited Members | |
| Public Types inherited from CbaseItem | |
| enum | nodeType_t { NODETYPE_UNDEFINED =0x0 , NODETYPE_INPUT =0x01 , NODETYPE_TASK =0x2 , NODETYPE_OUTPUT =0x04 } |
| The nodeType_t enum defines the different types a node can use. Multiple values can be defined with a bitwise. i.e. NODETYPE_INPUT|NODETYPE_TASK for a node being in both Input and Task sections . More... | |
| Static Public Member Functions inherited from CbaseItem | |
| static QList< CbaseItem * > | getCopyFromItemList (const QList< CbaseItem * > &itemList, QObject *parentForCopy=nullptr) |
| static CnameConvention | composeNameConvention (const CnameConvention &nc, const CnameConvention &defaultNC) |
| Composes a name convention from two name conventions. | |
| Protected Member Functions inherited from CbaseItem | |
| CworkflowsMgr * | findWorkflowsMgr () const |
| Finds the workflows manager associated with this item. | |
The Cpython class provides functionality to manage Python Nodes.
To create a node, you need to generate three files:
Naming Convention:
Every Python-based node must define the following functions:
In addition to the required functions, the following optional functions can be implemented:
For further details, refer to the official documentation: SGO Python API Documentation
The Cpython class provides functionality to manage Python Nodes.
The Cpython class extends Ctask to provide Python-based node functionality. It allows creating nodes with custom Python code that can be executed within the workflow system. This class handles the integration of Python code with the workflow system, including property management, connector handling, file drop operations, and execution queue management.
|
slot |
Adds an action to the Node Context Menu If there Action already exists, this function does nothing.
| actionName |
|
slot |
Adds a conector called name of type type and mode mode.
| name | |
| type | |
| mode |
|
slot |
Adds an encrypted property to the node.
Encrypted properties can be included in the Property Editor via the node XSD like any other property. When shown in the GUI, they are displayed as a password/masked field (the clear-text value is never revealed). The value is stored encrypted when persisted (node defaults, projects, etc.), but can be accessed programmatically by the node at runtime.
| name | The name of the property to add. If the name starts with an underscore (_), the property will be created as internal and will not be stored in the .mwf workflow file. |
| value | The default value for the property (optional) |
|
slot |
Add a permanent critical error that will be reported when evaluating the isReady status. Permanent errors are stored and remain active until removed with clearAllPermanentErrors(), clearPermanentErrorById(), or clearPermanentErrorsByGroup().
Important: For errors in init, isReady, and process functions, use the regular critical and error methods instead. Permanent errors should only be used in functions that are not part of the core validation/execution process.
| id | Error ID |
| description | Error description |
| group | Optional parameter used to group errors, so they can be removed later as a group |
|
slot |
Add a permanent error that will be reported when evaluating the isReady status. Permanent errors are stored and remain active until removed with clearAllPermanentErrors(), clearPermanentErrorById(), or clearPermanentErrorsByGroup().
Important: For errors in init, isReady, and process functions, use the regular critical and error methods instead. Permanent errors should only be used in functions that are not part of the core validation/execution process.
| id | Error ID |
| description | Error description |
| group | Optional parameter used to group errors, so they can be removed later as a group |
|
slot |
Adds a property called name with default value value.
| name | The name of the property to add. If the name starts with an underscore (_), the property will be created as internal and will not be stored in the .mwf workflow file. |
| value | The default value for the property (optional) |
|
slot |
adds a template manager for a property.
| filePath | to the template definition the obj file should look like this: { "myNodeProperty": [ {"undefinedOption": {}}, {"option 1": { "relatedProperty1": "property1 Value" "relatedProperty2": "property2 Value", }}, {"option 2": { "relatedProperty1": "property1 Value" "relatedProperty2": "property2 Value", }} ] } This file will create a the following pull down: "undefinedOption", "option 1", "option 2" and selecting it will affect the properties: "relatedProperty1" and "relatedProperty1" Please notice the structure of "myNodeProperty" is an array of objects. The reason of using one array, is to preserve the order of the objects in the pull down list. You can create an array of a single object, and add all the elements to it. but in that case the pull down list is not guranteed to maintain the file order br> So, if you want to maintain the file order in the pulldown,it is recomended to create an array of single object elements. |
| property | to attatch to In the previous file example, it it is "myNodeProperty" |
|
slot |
returns the new CexecutionQueue instance
This link can be used to Queue external applications to be multithreaded
It is important to delete this instance when it is no longer needed by calling the deleteLater method
| maxThreads |
|
slot |
returns the new CexternalAppNodeLink instance
This link can be used to execute external applications from the python node using all the CexternalAppNodeLink functionality It is important to delete this instance when it is no longer needed by calling the deleteLater method
|
slot |
Delete one permanent error with the specified id.
| id | to clear |
|
slot |
Delete all permanent errors included in the specified errors group.
| group | to delete |
|
overridevirtual |
Allows the node to evaluate python code.
Reimplemented from CbaseItem.
|
slot |
gets the node attribute's Store This repository can be used to store information inside the node
That information is persistant along multiple executions. So It is perfect to cache data that needs to be calculated only once. It can also be used to pass information between node functions (from init to process, or any other combination)
|
slot |
Removes an action to the Node Context Menu If there Action does not exist, this function does nothing.
| actionName |
|
slot |
Enables/disables the ability to create connectors with drag and drop.
| enabled | boolean value to enable/Disable this mode |
| name | the connector name |
| label | the label to use, if it is different to the name (Default value is name) |
|
slot |
sets the Class name to display in the Finder The class ID will be the valid variable name related with this string (Removing space and other unsupported variable name characters) If this function is not called, the file Name will be used If called, it must be called from the init funcion.
| name |
|
slot |
Set the list of File Masks supported by the node
example: setDropSupportedFileMasks(["*.mov", "*.mp4"]).
| dropSupportedFileMasks | list of masks to accept (i.e: ["jpg","jpeg"] if the list is empty, all Files are accepted To disable the acceptance set the dropToProperty name to empty an string |
|
slot |
Set the File Types supported
.
| types | bitwise of supported types: 1 = Directories 2 = Files |
|
slot |
Assigns the name of the property that will accept the drop file actions
an empty value means no property is unassigned
.
| dropToProperty |
|
slot |
Sets the node types that this Python node supports.
| types | Bitwise for the supported Node Types. The constants are defined in CbaseItem and the possible values are: NODETYPE_INPUT=1 NODETYPE_TASK=2 NODETYPE_OUTPUT=4 |
|
overridevirtual |
If defined in Python, This function is called when the workflow finishes the execution.
| success | True if the workflow finished correctly |