ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/sites.py
Revision: 1.3
Committed: Mon Sep 19 21:45:41 2011 UTC (13 years, 7 months ago) by paus
Content type: text/x-python
Branch: MAIN
CVS Tags: Mit_025c_branch1, Mit_025c_branch0, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2
Branch point for: Mit_025c_branch
Changes since 1.2: +9 -2 lines
Log Message:
Reinstate the bin and python areas.

File Contents

# 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 paus 1.3 usage += " [ --dbs=<name> ]\n"
10 paus 1.2 usage += " --help\n"
11    
12     # Define the valid options which can be specified and check out the command line
13 paus 1.3 valid = ['block=','dbs=','help']
14 paus 1.2 try:
15     opts, args = getopt.getopt(sys.argv[1:], "", valid)
16     except getopt.GetoptError, ex:
17     print usage
18     print str(ex)
19     sys.exit(1)
20    
21     # --------------------------------------------------------------------------------------------------
22     # Get all parameters for the production
23     # --------------------------------------------------------------------------------------------------
24     # Set defaults for each option
25     block = None
26 paus 1.3 dbs = ''
27 paus 1.2
28     # Read new values from the command line
29     for opt, arg in opts:
30     if opt == "--help":
31     print usage
32     sys.exit(0)
33     if opt == "--block":
34     block = arg
35 paus 1.3 if opt == "--dbs":
36     dbs = arg
37 paus 1.2
38     # Deal with obvious problems
39     if block == None:
40     cmd = "--block= required parameter not provided."
41     raise RuntimeError, cmd
42    
43     #---------------------------------------------------------------------------------------------------
44     # main
45     #---------------------------------------------------------------------------------------------------
46     # find relevant site for this block
47 paus 1.3 cmd = "dbs search "
48     if dbs != '':
49     cmd += " --url=" + dbs
50     cmd += " --query=\"find site where block=" + block + "\""
51 paus 1.2 cmd += "| grep -v DBS | grep \\\."
52     sites = []
53     siteText = ''
54     for line in os.popen(cmd).readlines():
55     line = line[:-1]
56     sites.append(line)
57     if siteText != '':
58     siteText += ','
59     siteText += line
60    
61     print siteText