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: |
23 |
|
# -------------------------------------------------------------------------------------------------- |
24 |
|
# Set defaults for each option |
25 |
|
block = None |
26 |
+ |
dbs = '' |
27 |
|
|
28 |
|
# Read new values from the command line |
29 |
|
for opt, arg in opts: |
32 |
|
sys.exit(0) |
33 |
|
if opt == "--block": |
34 |
|
block = arg |
35 |
+ |
if opt == "--dbs": |
36 |
+ |
dbs = arg |
37 |
|
|
38 |
|
# Deal with obvious problems |
39 |
|
if block == None: |
44 |
|
# main |
45 |
|
#--------------------------------------------------------------------------------------------------- |
46 |
|
# find relevant site for this block |
47 |
< |
cmd = "dbs search --query=\"find site where block=" + block + "\"" |
47 |
> |
cmd = "dbs search " |
48 |
> |
if dbs != '': |
49 |
> |
cmd += " --url=" + dbs |
50 |
> |
cmd += " --query=\"find site where block=" + block + "\"" |
51 |
|
cmd += "| grep -v DBS | grep \\\." |
52 |
|
sites = [] |
53 |
|
siteText = '' |
58 |
|
siteText += ',' |
59 |
|
siteText += line |
60 |
|
|
61 |
+ |
if siteText[0] == ',': |
62 |
+ |
siteText = siteText[1:] |
63 |
+ |
|
64 |
|
print siteText |