Skip to content

Commit e7a497c

Browse files
committed
argument to change rucio username
1 parent 226846e commit e7a497c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

get_files_on_disk.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ def getOS():
1111
osv = subprocess.check_output(shlex.split(cmd), encoding="utf-8").rstrip()
1212
return osv
1313

14-
def getHosted(dataset):
14+
def getHosted(dataset, user):
1515
"""Gets list of files on disk for a dataset, and list of sites along with how many files each site has"""
1616
osv = getOS()
1717
rucio_path = f'/cvmfs/cms.cern.ch/rucio/x86_64/rhel{osv}/py3/current'
1818
os.environ['RUCIO_HOME'] = rucio_path
19-
os.environ['RUCIO_ACCOUNT'] = getpass.getuser()
19+
os.environ['RUCIO_ACCOUNT'] = user
2020
full_rucio_path = glob.glob(rucio_path+'/lib/python*.*')[0]
2121
sys.path.insert(0,full_rucio_path+'/site-packages/')
2222

@@ -49,9 +49,9 @@ def sitecond(site):
4949
sys.path.pop(0)
5050
return filelist, sitelist
5151

52-
def main(dataset, outfile=None, verbose=False):
52+
def main(dataset, user, outfile=None, verbose=False):
5353
"""Prints file list and site list"""
54-
filelist, sitelist = getHosted(dataset)
54+
filelist, sitelist = getHosted(dataset, user)
5555

5656
if verbose:
5757
print("Site list:")
@@ -62,13 +62,15 @@ def main(dataset, outfile=None, verbose=False):
6262
if outfile is not None: file.close() # pylint: disable=multiple-statements
6363

6464
if __name__=="__main__":
65+
default_user = getpass.getuser()
6566
parser = argparse.ArgumentParser(
6667
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
6768
description="Find all available files (those hosted on disk) for a given dataset",
6869
)
6970
parser.add_argument("-o","--outfile",type=str,default=None,help="write to this file instead of stdout")
71+
parser.add_argument("-u","--user",type=str,default=default_user,help="username for rucio")
7072
parser.add_argument("-v","--verbose",default=False,action="store_true",help="print extra information (site list)")
7173
parser.add_argument("dataset",type=str,help="dataset to query")
7274
args = parser.parse_args()
7375

74-
main(args.dataset, outfile=args.outfile, verbose=args.verbose)
76+
main(args.dataset, args.user, outfile=args.outfile, verbose=args.verbose)

0 commit comments

Comments
 (0)