...
In order to find the hook files the file name must match exactly. Please see list below.
The example scripts can be found here:
https://github.com/das-element/resources/tree/main/scripts/hooks/examples
Script | Description |
---|---|
| Gets executed before each transcoding task |
| Gets executed after each transcoding task |
| Gets executed before the file paths get loaded into the ingest view |
| Gets execture before the library elements get exported |
The software follows this order looking for Python Hook files.
directory defined in the
$DASELEMENT_HOOKS
environment variabledirectory defined in the
$DASELEMENT_RESOURCES/scripts/hooks
environment variableyour local
.das-element
folder (for Linux:~/.das-element/scripts/hooks
or for Windows%homepath%/.das-element/scripts/hooks
)
Info |
---|
The result data needs to be JSON serializable. |
Pre Render Hook
The input is the resolver data dictionary
which will be used to resolve the path pattern. You can modify it here before the transcoding task gets processed.
...
This hook can be used to edit, reformat or add additional values to the export elements from the settings page of the library elements.
...
Info |
---|
Tip: use this hook to create a CSV file that you can import into Shotgrid |
...
https://github.com/das-element/resources/blob/main/scripts/hooks/examples/shotgrid/pre_export.py
Troubleshooting
To get a better idea what’s happening inside the hook files you can follow these steps:
...
inside the Python hook file you can add print statements
Code Block |
---|
print(item)
print(item['path']) |
...
start a terminal/command prompt
...
activate the debug mode -set the environment variable
Code Block |
---|
# Linux/MacOS
export DASELEMENT_LOG_LEVEL=debug
# Windows
set DASELEMENT_LOG_LEVEL=debug |
...
now run the software via the command line
Code Block |
---|
# Linux
/opt/das-element-1.2.1/das-element-1.2.1
# MacOS
/Application
# Windows
C:\Program Files |
...
Logger inside python file
Since version 2.1.2
you can directly access the logger inside the hook files.
Code Block |
---|
def main(*args, logger=none):
items = args[0]
# use the Das Element logger
# will log to ~/.das-element/logs/
logger.warning('This is a warning!')
return items
if __name__ == '__main__':
main(sys.argv[1:]) |
Example for pre_load_ingest.py
Code Block |
---|
import logging
def main(*args, logger=none):
items = args[0]
logger.warning('This is a warning!') # <- use the Das Element logger (~/.das-element/logs/)
logging.warning('This is a warning!') # <- use the default logging module
for item in items:
print(item) # <- this print() will be output to the console
return items
if __name__ == '__main__':
main(sys.argv[1:]) |