--copy-to fix, sys.exit fixes

pull/1297/head
Piero Toffanin 2021-06-09 12:28:44 -04:00
rodzic f89545ace9
commit f63da10342
5 zmienionych plików z 17 dodań i 10 usunięć

Wyświetl plik

@ -57,8 +57,9 @@ class ODMLogger:
'type': level_name.lower()
})
def init_json_output(self, output_file, args):
self.json_output_file = output_file
def init_json_output(self, output_files, args):
self.json_output_files = output_files
self.json_output_file = output_files[0]
self.json = {}
self.json['odmVersion'] = odm_version()
self.json['memory'] = memory()
@ -137,8 +138,13 @@ class ODMLogger:
def close(self):
if self.json is not None and self.json_output_file is not None:
with open(self.json_output_file, 'w') as f:
f.write(json.dumps(self.json, indent=4))
try:
with open(self.json_output_file, 'w') as f:
f.write(json.dumps(self.json, indent=4))
for f in self.json_output_files[1:]:
shutil.copy(self.json_output_file, f)
except Exception as e:
print("Cannot write log.json: %s" % str(e))
logger = ODMLogger()

Wyświetl plik

@ -50,13 +50,12 @@ class OSFMContext:
# Check that a reconstruction file has been created
if not self.reconstructed():
log.ODM_ERROR("The program could not process this dataset using the current settings. "
raise system.ExitException("The program could not process this dataset using the current settings. "
"Check that the images have enough overlap, "
"that there are enough recognizable features "
"and that the images are in focus. "
"You could also try to increase the --min-num-features parameter."
"The program will now exit.")
exit(1)
def setup(self, args, images_path, reconstruction, append_config = [], rerun=False):

Wyświetl plik

@ -45,8 +45,7 @@ class LocalRemoteExecutor:
log.ODM_WARNING("LRE: The node seems to be offline! We'll still process the dataset, but it's going to run entirely locally.")
self.node_online = False
except Exception as e:
log.ODM_ERROR("LRE: An unexpected problem happened while opening the node connection: %s" % str(e))
exit(1)
raise system.ExitException("LRE: An unexpected problem happened while opening the node connection: %s" % str(e))
def set_projects(self, paths):
self.project_paths = paths

Wyświetl plik

@ -27,7 +27,11 @@ class ODMApp:
if args.debug:
log.logger.show_debug = True
log.logger.init_json_output(os.path.join(args.project_path, "log.json"), args)
json_log_paths = [os.path.join(args.project_path, "log.json")]
if args.copy_to:
json_log_paths.append(args.copy_to)
log.logger.init_json_output(json_log_paths, args)
dataset = ODMLoadDatasetStage('dataset', args, progress=5.0,
verbose=args.verbose)

Wyświetl plik

@ -198,7 +198,6 @@ class ODMReport(types.ODM_Stage):
octx.export_report(os.path.join(tree.odm_report, "report.pdf"), odm_stats, self.rerun())
# TODO: does this warrant a new stage?
# TODO: move to pipeline end ?
if args.copy_to:
try:
copy_paths([os.path.join(args.project_path, p) for p in get_processing_results_paths()], args.copy_to, self.rerun())