Revision: | 1.2 |
Committed: | Sat Jun 5 02:36:28 2010 UTC (14 years, 11 months ago) by paus |
Content type: | text/x-python |
Branch: | MAIN |
CVS Tags: | Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a |
Changes since 1.1: | +54 -0 lines |
Log Message: | Wow I forgot all about my cvs. |
# | User | Rev | Content |
---|---|---|---|
1 | paus | 1.2 | #!/usr/bin/env python |
2 | #--------------------------------------------------------------------------------------------------- | ||
3 | # Simple interface to command line DBS to prepare my crabTask input files. | ||
4 | #--------------------------------------------------------------------------------------------------- | ||
5 | import os,sys,types,string,getopt | ||
6 | |||
7 | # Define string to explain usage of the script | ||
8 | usage = "Usage: site.py --block=<name>\n" | ||
9 | usage += " --help\n" | ||
10 | |||
11 | # Define the valid options which can be specified and check out the command line | ||
12 | valid = ['block=','help'] | ||
13 | try: | ||
14 | opts, args = getopt.getopt(sys.argv[1:], "", valid) | ||
15 | except getopt.GetoptError, ex: | ||
16 | print usage | ||
17 | print str(ex) | ||
18 | sys.exit(1) | ||
19 | |||
20 | # -------------------------------------------------------------------------------------------------- | ||
21 | # Get all parameters for the production | ||
22 | # -------------------------------------------------------------------------------------------------- | ||
23 | # Set defaults for each option | ||
24 | block = None | ||
25 | |||
26 | # Read new values from the command line | ||
27 | for opt, arg in opts: | ||
28 | if opt == "--help": | ||
29 | print usage | ||
30 | sys.exit(0) | ||
31 | if opt == "--block": | ||
32 | block = arg | ||
33 | |||
34 | # Deal with obvious problems | ||
35 | if block == None: | ||
36 | cmd = "--block= required parameter not provided." | ||
37 | raise RuntimeError, cmd | ||
38 | |||
39 | #--------------------------------------------------------------------------------------------------- | ||
40 | # main | ||
41 | #--------------------------------------------------------------------------------------------------- | ||
42 | # find relevant site for this block | ||
43 | cmd = "dbs search --query=\"find site where block=" + block + "\"" | ||
44 | cmd += "| grep -v DBS | grep \\\." | ||
45 | sites = [] | ||
46 | siteText = '' | ||
47 | for line in os.popen(cmd).readlines(): | ||
48 | line = line[:-1] | ||
49 | sites.append(line) | ||
50 | if siteText != '': | ||
51 | siteText += ',' | ||
52 | siteText += line | ||
53 | |||
54 | print siteText |