2# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
4import glob
5import sys
6
7if __name__=="__main__":
8
9import argparse
10 parser = argparse.ArgumentParser(prog="l1calo-dq-file",description="Tries to obtain a path to a DQ HIST file",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
28 pattern = f"{project}:{project}.{int(args.run):08}.{args.stream}.merge.HIST.{'f' if args.bulk else 'x'}*"
29try:
30 datasets = [d for d in subprocess.run(["rucio","list-dids","--short", pattern],stdout=subprocess.PIPE).stdout.decode("utf-8").split('\n') if d !='']
31except FileNotFoundError:
32print("No file found. 'lsetup rucio' if you want to look further for the files",file=sys.stderr)
33 exit(1)
34 files = [f.split(",")[0] for f in subprocess.run(["rucio","list-files","--csv"]+datasets,stdout=subprocess.PIPE).stdout.decode("utf-8").split('\n') if f!='']
38 filePaths = [f[29:] for f in subprocess.run(["rucio", "list-file-replicas", "--pfns", "--rses", "CERN-PROD_DATADISK"]+files,stdout=subprocess.PIPE).stdout.decode("utf-8").split('\n')]