File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change 11import os
22import shutil
3+ import time
4+ import platform
35
46# from projects import get_records_from_datadir, fix_config_paths
57from deepethogram import projects
@@ -26,7 +28,27 @@ def change_to_deepethogram_directory():
2628
2729
2830def clean_test_data ():
29- if os .path .isdir (project_path ):
31+ if not os .path .isdir (project_path ):
32+ return
33+
34+ # On Windows, we need to handle file permission errors
35+ if platform .system () == 'Windows' :
36+ max_retries = 3
37+ for i in range (max_retries ):
38+ try :
39+ shutil .rmtree (project_path )
40+ break
41+ except PermissionError :
42+ if i < max_retries - 1 :
43+ time .sleep (1 ) # Wait a bit for file handles to be released
44+ continue
45+ else :
46+ # If we still can't delete after retries, try to ignore errors
47+ try :
48+ shutil .rmtree (project_path , ignore_errors = True )
49+ except :
50+ pass # If we still can't delete, just continue
51+ else :
3052 shutil .rmtree (project_path )
3153
3254
You can’t perform that action at this time.
0 commit comments