6 |
|
|
7 |
|
# Define string to explain usage of the script |
8 |
|
usage = "Usage: site.py --block=<name>\n" |
9 |
+ |
usage += " [ --dbs=<name> ]\n" |
10 |
|
usage += " --help\n" |
11 |
|
|
12 |
|
# Define the valid options which can be specified and check out the command line |
13 |
< |
valid = ['block=','help'] |
13 |
> |
valid = ['block=','dbs=','help'] |
14 |
|
try: |
15 |
|
opts, args = getopt.getopt(sys.argv[1:], "", valid) |
16 |
|
except getopt.GetoptError, ex: |
22 |
|
# Get all parameters for the production |
23 |
|
# -------------------------------------------------------------------------------------------------- |
24 |
|
# Set defaults for each option |
25 |
< |
block = None |
25 |
> |
block = None |
26 |
> |
dbs = '' |
27 |
> |
private = False |
28 |
|
|
29 |
|
# Read new values from the command line |
30 |
|
for opt, arg in opts: |
33 |
|
sys.exit(0) |
34 |
|
if opt == "--block": |
35 |
|
block = arg |
36 |
+ |
if opt == "--dbs": |
37 |
+ |
dbs = arg |
38 |
|
|
39 |
|
# Deal with obvious problems |
40 |
|
if block == None: |
41 |
|
cmd = "--block= required parameter not provided." |
42 |
|
raise RuntimeError, cmd |
43 |
|
|
44 |
+ |
# is it a private production |
45 |
+ |
f = block.split('#') |
46 |
+ |
if f[1] == "00000000-0000-0000-0000-000000000000": |
47 |
+ |
private = True |
48 |
+ |
#print ' Attention -- private dataset identified.' |
49 |
+ |
|
50 |
|
#--------------------------------------------------------------------------------------------------- |
51 |
|
# main |
52 |
|
#--------------------------------------------------------------------------------------------------- |
53 |
+ |
# handle private production first |
54 |
+ |
if private: |
55 |
+ |
print block + ' : ' + 'se01.cmsaf.mit.edu' |
56 |
+ |
sys.exit() |
57 |
+ |
|
58 |
|
# find relevant site for this block |
59 |
< |
cmd = "dbs search --query=\"find site where block=" + block + "\"" |
59 |
> |
cmd = "dbs search " |
60 |
> |
if dbs != '': |
61 |
> |
cmd += " --url=" + dbs |
62 |
> |
cmd += " --query=\"find site where block=" + block + "\"" |
63 |
|
cmd += "| grep -v DBS | grep \\\." |
64 |
|
sites = [] |
65 |
|
siteText = '' |
70 |
|
siteText += ',' |
71 |
|
siteText += line |
72 |
|
|
73 |
+ |
if siteText[0] == ',': |
74 |
+ |
siteText = siteText[1:] |
75 |
+ |
|
76 |
|
print siteText |