def make_temp_dir(filename, signal=False):
    """Creates a temporary folder and returns the joined filename"""
    try:

        if ((testParams['user_tempdir'] is not None and testParams['user_tempdir'] != '') and
                        testParams['actual_tempdir'] == ''):
            testParams['actual_tempdir'] = testParams['user_tempdir']

        if not os.path.isdir(testParams['actual_tempdir']):
            os.makedirs(testParams['actual_tempdir'])

        return os.path.join(testParams['actual_tempdir'], filename)
    except __HOLE__ as exc:
        actual_tempdir = os.path.join(tempfile.gettempdir(), testParams['tempdir'])

        if signal:
            errwrite('I used `tempfile.gettempdir()` to create the temporary folder '
                             '`%s`.' % actual_tempdir)
        testParams['actual_tempdir'] = actual_tempdir
        if not os.path.isdir(testParams['actual_tempdir']):
            try:
                os.makedirs(testParams['actual_tempdir'])
            except Exception:
                pass # race condition

        return os.path.join(actual_tempdir, filename)
    except:
        get_root_logger().error('Could not create a directory.')
        raise
dataset/ETHPy150Open SmokinCaterpillar/pypet/pypet/tests/testutils/ioutils.py/make_temp_dir