5 from __future__
import print_function
7 import subprocess, threading, os, sys
13 parser = argparse.ArgumentParser(description=
'Checks if dataset is accessible through FAX.')
14 parser.add_argument(
'dataset', type=str, help=
'Dataset name')
15 parser.add_argument(
'-af',
'--accessfile', action=
'store_const', const=
'1', help=
'try to open the first root file of the dataset using root. ')
16 parser.add_argument(
'-aa',
'--accessall', action=
'store_const', const=
'1', help=
'try to open all the root files of the dataset using root. ')
18 args = vars(parser.parse_args())
21 import dq2.clientapi.cli.cliutil
22 from dq2.common.cli.DQDashboardTool
import DQDashboardTool
23 from dq2.clientapi.cli.cliutil
import getDQ2
24 from dq2.filecatalog.lfc.lfcconventions
import to_native_lfn
26 print (
"Environment not set [error importing DQ2 dependencies]!")
36 def run(self, timeout):
39 self.
process = subprocess.Popen(self.
cmd, shell=
True)
42 thread = threading.Thread(target=target)
47 print (
'Terminating process')
62 ho=ho.replace(
"root://",
"")
63 self.
host=ho.split(
":")[0]
65 self.
port=ho.split(
":")[1]
68 if (what>=0
and self.redirector!=what):
return
69 print (
'name:', self.
name,
'\thost:', self.
host,
'\tport:', self.
port )
74 req = urllib2.Request(
"http://atlas-agis-api-0.cern.ch/request/service/query/get_se_services/?json&state=ACTIVE&flavour=XROOTD",
None)
75 opener = urllib2.build_opener()
80 ns =
site( s[
"rc_site"], s[
"endpoint"] )
86 print (
"Unexpected error:", sys.exc_info()[0] )
93 req = urllib2.Request(
"http://atlas-agis-api-0.cern.ch/request/ddmendpoint/query/list/?json&state=ACTIVE",
None)
94 opener = urllib2.build_opener()
99 if s[
"rc_site"]==c.name:
101 allddms.add(s[
"name"])
106 print (
"Unexpected error:", sys.exc_info()[0] )
117 if line.startswith(
'Multiple'):
break
119 if line.count(
':')==0:
continue
123 if line[0]==
'INCOMPLETE':
124 if len(line[1])==0:
continue
131 if line[0]==
'COMPLETE':
132 if len(line[1])==0:
continue
133 rep=line[1].
split(
',')
142 for d
in dsets.keys():
143 print (d,
'\tcomplete replicas:',dsets[d][1],
'\tincomplete:',dsets[d][0])