modify_pytwin_working_dir#

pytwin.modify_pytwin_working_dir(new_path, erase=True)#

Modify the global PyTwin working directory.

By default, a temporary directory is used by PyTwin as working directory. This temporary directory is automatically cleaned up at exit of the python process that imported pytwin. When this method is used, the new PyTwin working directory won’t be deleted at python process exit. Note that this may lead to an overflow of the working directory.

Parameters:
new_path: str

Absolute path to the working directory to use for PyTwin. The directory is created if it does not exist. This directory is kept alive at python process exit.

erase: bool, optional

Whether to erase a non-empty existing working directory. The default is True, in which case the existing working directory is erased and a new one is created. If False, the existing working directory is used as it is. This parameter has no effect if the directory does not exist.

Raises:
PyTwinSettingsError

If provided path is None.

If provided path does not exist and some parent directories do not exist or the last parent directory does not have write permission.

If erase is not a Boolean value.

Examples

>>> # Modify working directory
>>> from pytwin import modify_pytwin_working_dir
>>> modify_pytwin_working_dir('path_to_new_working_dir', erase=False)