def removeBackupLoop(retryTime=.1, printFailure=False):
    assert os.path.isdir(backup_dir), "Maya user backup does not exist: %s" % backup_dir
    
    print "restoring Maya user directory", app_dir

    lastException = None
    start = time.time()
    while os.path.isdir( app_dir ):
        # Check elapsed time AFTER trying to delete dir -
        # otherwise, if some other thread gets priority while we are
        # sleeping, and it's a while before the thread wakes up, we might
        # check once when almost no time has passed, sleep, wake up after
        # a lot of time has passed, and not check again...
        try:
            tempdir = os.path.join(tempfile.gettempdir(), 'maya')
            if os.path.exists(tempdir):
                shutil.rmtree( tempdir )
            shutil.move(app_dir, tempdir)
            shutil.rmtree( tempdir )
        except Exception, e:
            lastException = e
            # print("print - unable to delete '%s' - elapsed time: %f" %
            #        (app_dir, time.time() - start))
            time.sleep(.2)
        else:
            lastException = None
            
        if start - time.time() > retryTime:
            break

    if lastException is not None:
        if printFailure:
            print('Error deleting "%s" - manually delete and rename/move "%s": %s' %
                   (app_dir, backup_dir, lastException))
        raise RemoveBackupError
    else:  
        shutil.move( backup_dir, app_dir )
        print "done"
dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.3/tests/pymel_test.py/removeBackupLoop/swapped operands of `-`