diff --git a/opendm/log.py b/opendm/log.py index cd3de35a..671521db 100644 --- a/opendm/log.py +++ b/opendm/log.py @@ -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() diff --git a/opendm/osfm.py b/opendm/osfm.py index 9077a72f..fae2d59c 100644 --- a/opendm/osfm.py +++ b/opendm/osfm.py @@ -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): diff --git a/opendm/remote.py b/opendm/remote.py index 89e22af3..30a4daea 100644 --- a/opendm/remote.py +++ b/opendm/remote.py @@ -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 diff --git a/stages/odm_app.py b/stages/odm_app.py index 9a0ca045..04d5e217 100644 --- a/stages/odm_app.py +++ b/stages/odm_app.py @@ -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) diff --git a/stages/odm_report.py b/stages/odm_report.py index f297b9a6..9e07c4f1 100644 --- a/stages/odm_report.py +++ b/stages/odm_report.py @@ -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())