'Instantiate a job directory.
:param path: The path of the directory. If None a temporary directory
will be created instead.
:type path: string
:param is_writable: If True, expect the directory to be writable.
:type is_writable: bool
:raises: :class:`MissingDirectoryException` if ``is_writable=False``
and the directory does not exist.
:raises: :class:`UnwritableDirectoryException` if ``is_writable=True``
and the directory exists but is not writable.
:raises: :class:`UncreatableDirectoryException` if ``is_writable=True``
the directory does not exist and it cannot be created.'

def __init__(self, path, is_writable=False):

    if (path is None):
        if is_writable:
            self._tempdir = autotemp.tempdir(unique_id='autotest')
            self.path = self._tempdir.name
        else:
            raise self.MissingDirectoryException(path)
    else:
        self._tempdir = None
        self.path = path
    self._ensure_valid(is_writable)
