@@ -11,12 +11,12 @@ def getOS():
11
11
osv = subprocess .check_output (shlex .split (cmd ), encoding = "utf-8" ).rstrip ()
12
12
return osv
13
13
14
- def getHosted (dataset ):
14
+ def getHosted (dataset , user ):
15
15
"""Gets list of files on disk for a dataset, and list of sites along with how many files each site has"""
16
16
osv = getOS ()
17
17
rucio_path = f'/cvmfs/cms.cern.ch/rucio/x86_64/rhel{ osv } /py3/current'
18
18
os .environ ['RUCIO_HOME' ] = rucio_path
19
- os .environ ['RUCIO_ACCOUNT' ] = getpass . getuser ()
19
+ os .environ ['RUCIO_ACCOUNT' ] = user
20
20
full_rucio_path = glob .glob (rucio_path + '/lib/python*.*' )[0 ]
21
21
sys .path .insert (0 ,full_rucio_path + '/site-packages/' )
22
22
@@ -49,9 +49,9 @@ def sitecond(site):
49
49
sys .path .pop (0 )
50
50
return filelist , sitelist
51
51
52
- def main (dataset , outfile = None , verbose = False ):
52
+ def main (dataset , user , outfile = None , verbose = False ):
53
53
"""Prints file list and site list"""
54
- filelist , sitelist = getHosted (dataset )
54
+ filelist , sitelist = getHosted (dataset , user )
55
55
56
56
if verbose :
57
57
print ("Site list:" )
@@ -62,13 +62,15 @@ def main(dataset, outfile=None, verbose=False):
62
62
if outfile is not None : file .close () # pylint: disable=multiple-statements
63
63
64
64
if __name__ == "__main__" :
65
+ default_user = getpass .getuser ()
65
66
parser = argparse .ArgumentParser (
66
67
formatter_class = argparse .ArgumentDefaultsHelpFormatter ,
67
68
description = "Find all available files (those hosted on disk) for a given dataset" ,
68
69
)
69
70
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" )
70
72
parser .add_argument ("-v" ,"--verbose" ,default = False ,action = "store_true" ,help = "print extra information (site list)" )
71
73
parser .add_argument ("dataset" ,type = str ,help = "dataset to query" )
72
74
args = parser .parse_args ()
73
75
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