Why not use the Python tempfile module: https://docs.python.org/3/library/tempfile.html
It's very easy:
import tempfile
temp_dir = tempfile.TemporaryDirectory()
# Manipulate the directory contents here
Why not use the Python tempfile module: https://docs.python.org/3/library/tempfile.html
It's very easy:
import tempfile
temp_dir = tempfile.TemporaryDirectory()
# Manipulate the directory contents here
Hey David, thanks for your answer I also found this option myself. However my question is more on why the TempPathnameCreator and the PythonCaller are unable to work together.
Hey David, thanks for your answer I also found this option myself. However my question is more on why the TempPathnameCreator and the PythonCaller are unable to work together.
The TempPathnameCreator only reserves the name of a temporary directory that is guaranteed to be unique, it doesn't actually create the directory for you. It can behave this way since practically all functionality in FME that writes a file will automatically recursively create any needed (sub-)directories.
This is not the case in Python, where you'll have to explicitly create all directories before trying to access them, e.g. using
import os
os.makedirs(feature.getAttribute('_pathname'))
The Python function tempfile.TemporaryDirectory() will not only reserve the directory name, but it will also create the directory for you.