Remove workdir only when its defined
Despite `directory = path or self._workdir_name()`, `directory` can be
`None` because `self._workdir_name()` can return `None`. Hence removing
the directory only when the value is valid.
@@ -516,6 +516,7 @@ class Common(object):
def _workdir_cleanup(self, path=None):
""" Clean up the work directory """
directory = path or self._workdir_name()
+ if directory is not None:
if os.path.isdir(directory):
self.debug(f"Clean up workdir '{directory}'.", level=2)
shutil.rmtree(directory)
