6 import samweb_client
as swc
13 parser= argparse.ArgumentParser(epilog=examples, formatter_class=argparse.RawDescriptionHelpFormatter)
15 gp = parser.add_mutually_exclusive_group()
16 gp.add_argument(
"files",
20 help=
"Files to consider. Can be specified as a full /pnfs path, or just the SAM filename",
22 gp.add_argument(
"-d",
"--dataset",
25 help=
"Name of the SAM dataset to check cache status of",
27 gp.add_argument(
"-q",
"--dim",
28 metavar=
"\"DIMENSION\"",
30 help=
"sam dimensions to check cache status of",
33 parser.add_argument(
"-s",
"--sparse", type=int, dest=
'sparse',help=
"Sparsification factor. This is used to check only a portion of a list of files",default=1)
34 parser.add_argument(
"-ss",
"--snapshot", dest=
"snapshot", help=
"[Also requires -d] Use this snapshot ID for the dataset. Specify 'latest' for the most recent one.")
35 parser.add_argument(
"-v",
"--verbose", action=
"store_true", dest=
"verbose", default=
False, help=
"Print information about individual files")
36 parser.add_argument(
"-p",
"--prestage", action=
"store_true", dest=
"prestage", default=
False, help=
"Prestage the files specified")
37 parser.add_argument(
"-m",
"--method", choices=[
"rest",
"pnfs"], default=
"rest", help=
"Use this method to look up file status.")
39 args=parser.parse_args()
43 if args.method
in (
"rest"):
45 subprocess.check_call(shlex.split(
"setup_fnal_security --check"), stdout=
open(os.devnull), stderr=subprocess.STDOUT)
46 except subprocess.CalledProcessError:
47 print(
"Your proxy is expired or missing. Please run `setup_fnal_security` and then try again." )
50 filelist =
None if args.dataset_name
else args.files
52 sam = swc.SAMWebClient(
"dune")
61 print(
"Retrieving file list for SAM dataset definition name: '%s'..." % args.dataset_name, end=
"" )
64 thislist = sam.listFiles(defname=args.dataset_name)
72 if not (a%100): print(
"Locating files: %i/%i"%(a, len(thislist)), end=
'\r')
73 locs = sam.locateFile(f)
75 split_path = l[
'full_path'].
split(
':')
76 if split_path[0] ==
'enstore':
77 if args.method ==
"pnfs":
80 print( f,
"ONLINE" if this_cached
else "NEARLINE")
81 if this_cached: cached += 1
85 if "ONLINE" in qos: cached += 1
86 if "disk" in targetQos: pending += 1
91 print(
"%i/%i files are cached"%(cached, a))
95 except Exception
as e:
98 print(
'Unable to retrieve SAM information for dataset: %s' %(args.dataset_name) )
int open(const char *, int)
Opens a file descriptor.
def is_file_online_pnfs(f)
def get_file_qos(c, filename)
void split(std::string const &s, char c, OutIter dest)