<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def sandbox(cls, path):
        '''Ensures path exists before yielding, cleans up after'''
        # Ensure the path exists and is clean
        try:
            os.makedirs(path)
            logger.debug('Making %s' % path)
        except OSError:
            if not os.path.isdir(path):
                raise
        finally:
            cls.clean(path)
        # Then yield, but make sure to clean up the directory afterwards
        try:
            yield
        finally:
            cls.clean(path)