rm_r based rerun-all

pull/1401/head
Piero Toffanin 2022-01-03 09:21:46 -05:00
rodzic 15ed7602c0
commit d536e7ebfe
2 zmienionych plików z 17 dodań i 15 usunięć

Wyświetl plik

@ -83,3 +83,12 @@ def copy_paths(paths, destination, rerun):
elif os.path.isdir(p): elif os.path.isdir(p):
shutil.copytree(p, dst_path) shutil.copytree(p, dst_path)
log.ODM_INFO("Copying %s --> %s" % (p, dst_path)) log.ODM_INFO("Copying %s --> %s" % (p, dst_path))
def rm_r(path):
try:
if os.path.isdir(path) and not os.path.islink(path):
shutil.rmtree(path)
elif os.path.exists(path):
os.remove(path)
except:
log.ODM_WARNING("Cannot remove %s" % path)

23
run.py
Wyświetl plik

@ -12,7 +12,7 @@ from opendm import config
from opendm import system from opendm import system
from opendm import io from opendm import io
from opendm.progress import progressbc from opendm.progress import progressbc
from opendm.utils import double_quote, get_processing_results_paths from opendm.utils import get_processing_results_paths, rm_r
from opendm.loghelpers import args_to_dict from opendm.loghelpers import args_to_dict
from stages.odm_app import ODMApp from stages.odm_app import ODMApp
@ -47,20 +47,13 @@ if __name__ == '__main__':
# If user asks to rerun everything, delete all of the existing progress directories. # If user asks to rerun everything, delete all of the existing progress directories.
if args.rerun_all: if args.rerun_all:
log.ODM_INFO("Rerun all -- Removing old data") log.ODM_INFO("Rerun all -- Removing old data")
dirs_to_delete = [double_quote(os.path.join(args.project_path, p)) for p in get_processing_results_paths()] + [ for d in [os.path.join(args.project_path, p) for p in get_processing_results_paths()] + [
double_quote(os.path.join(args.project_path, "odm_meshing")), os.path.join(args.project_path, "odm_meshing"),
double_quote(os.path.join(args.project_path, "opensfm")), os.path.join(args.project_path, "opensfm"),
double_quote(os.path.join(args.project_path, "odm_texturing_25d")), os.path.join(args.project_path, "odm_texturing_25d"),
double_quote(os.path.join(args.project_path, "odm_filterpoints")), os.path.join(args.project_path, "odm_filterpoints"),
double_quote(os.path.join(args.project_path, "submodels")), os.path.join(args.project_path, "submodels")]:
] rm_r(d)
if sys.platform == 'win32':
for d in dirs_to_delete:
if os.path.isdir(d):
os.system("rmdir /S /Q " + dirs_to_delete)
else:
os.system("rm -rf " +
" ".join(dirs_to_delete))
app = ODMApp(args) app = ODMApp(args)
retcode = app.execute() retcode = app.execute()