From d9bc203d8048b7ed1acb45b70a85d711cd5a68ab Mon Sep 17 00:00:00 2001 From: Marcel R Date: Mon, 2 Jan 2023 10:38:48 +0100 Subject: [PATCH] Fix stat messages after file merigng in root contrib. --- law/contrib/root/util.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/law/contrib/root/util.py b/law/contrib/root/util.py index e0d31a13..cf6fece4 100644 --- a/law/contrib/root/util.py +++ b/law/contrib/root/util.py @@ -104,8 +104,13 @@ def hadd_cmd(input_paths, output_path): if code != 0: raise Exception("hadd failed") - task.publish_message("merged file size: {}".format(human_bytes( - output.stat().st_size, fmt=True))) + stat = output.exists(stat=True) + if not stat: + raise Exception("output '{}' not creating during merging".format(output.path)) + + # print the size + output_size = human_bytes(stat.st_size, fmt=True) + task.publish_message("merged file size: {}".format(output_size)) else: # when not local, we need to fetch files first into the cwd @@ -132,5 +137,10 @@ def callback(i): if code != 0: raise Exception("hadd failed") - task.publish_message("merged file size: {}".format(human_bytes( - tmp_out.stat().st_size, fmt=True))) + stat = tmp_out.exists(stat=True) + if not stat: + raise Exception("output '{}' not creating during merging".format(tmp_out.path)) + + # print the size + output_size = human_bytes(stat.st_size, fmt=True) + task.publish_message("merged file size: {}".format(output_size))