Revision: | 1.1 |
Committed: | Wed Feb 29 17:19:52 2012 UTC (13 years, 2 months ago) by fanzago |
Content type: | text/x-python |
Branch: | MAIN |
CVS Tags: | CRAB_2_9_1, CRAB_2_9_1_pre2, CRAB_2_9_1_pre1, CRAB_2_9_0, CRAB_2_9_0_pre2, CRAB_2_9_0_pre1, CRAB_2_8_8, CRAB_2_8_8_pre1, CRAB_2_8_7_patch3, CRAB_2_8_7_patch2, CRAB_2_8_7_patch1, CRAB_2_8_7, CRAB_2_8_7_pre2, CRAB_2_8_7_pre1, CRAB_2_8_6, CRAB_2_8_6_pre1, CRAB_2_8_5_patch3, CRAB_2_8_5_patch2, CRAB_2_8_5_patch1, CRAB_2_8_5, CRAB_2_8_5_pre5, CRAB_2_8_5_pre4, CRAB_2_8_5_pre3, CRAB_2_8_4_patch3, CRAB_2_8_5_pre2, CRAB_2_8_4_patch2, CRAB_2_8_5_pre1, CRAB_2_8_4_patch1, CRAB_2_8_4, CRAB_2_8_4_pre5, CRAB_2_8_4_pre4, CRAB_2_8_4_pre3, CRAB_2_8_4_pre2, CRAB_2_8_4_pre1, CRAB_2_8_3, CRAB_2_8_3_pre4, CRAB_2_8_3_pre3, CRAB_2_8_3_pre2, CRAB_2_8_3_pre1, CRAB_2_8_2_patch1, CRAB_2_8_2, CRAB_2_8_2_pre5, CRAB_2_8_2_pre4, CRAB_2_8_2_pre3, CRAB_2_8_2_pre2, CRAB_2_8_2_pre1, CRAB_2_8_1, HEAD |
Log Message: | analyses fjr files and prints surl of the Root files |
# | Content |
---|---|
1 | #!/usr/bin/env python |
2 | |
3 | import re, os |
4 | import getopt, sys |
5 | import FjrParser as fp |
6 | |
7 | def usage (prog_name): |
8 | print ">>> usage: " + prog_name + " -c <crab directory> [--help | -h] [--quite | -q]" |
9 | |
10 | def help (prog_name): |
11 | usage(prog_name) |
12 | |
13 | print """ |
14 | -c\t\t\t (Mandatory) CRAB project directory |
15 | --quiet, -q\t\t Wehn turned on, works silently |
16 | --help, -h\t\t Print this message |
17 | """ |
18 | sys.exit(1) |
19 | |
20 | if __name__ == '__main__': |
21 | (prog_path, prog_name) = os.path.split(sys.argv[0]) |
22 | if len(sys.argv) < 2: |
23 | help(prog_name) |
24 | |
25 | try: |
26 | opts, argv = getopt.getopt(sys.argv[1:], "hc:q", ["help","quiet"]) |
27 | except getopt.GetoptError, err: |
28 | print ">>> " + str(err) |
29 | help(prog_name) |
30 | |
31 | quiet = False |
32 | directory = "" |
33 | for o, a in opts: |
34 | if o == "-c": |
35 | directory = a |
36 | elif o in ("-q", "--quiet"): |
37 | quiet = True |
38 | elif o in ("-h", "--help"): |
39 | help(prog_name) |
40 | else: |
41 | print ">>> ", "unhandled option", o |
42 | help(prog_name) |
43 | |
44 | if directory == "" or not os.path.exists(directory): |
45 | print ">>> path <" + directory + "> may not exist" |
46 | help(prog_name) |
47 | |
48 | fjrs = fp.get_fjrs(directory) |
49 | for f in fjrs: |
50 | if not quiet: |
51 | print ">>> ", "processing fjr", f |
52 | |
53 | # parse fjr |
54 | try: |
55 | doc = fp.parse_xml(f) |
56 | except: |
57 | if not quiet: |
58 | print ">>> ", 'FrameworkJobReport', f, 'could not be parsed and is skipped' |
59 | continue |
60 | |
61 | # if the job finished successfully get the PFN |
62 | try: |
63 | if fp.is_goodfile(doc) : |
64 | (lfn, pfn, surl) = fp.get_filenames(doc) |
65 | print pfn |
66 | except: |
67 | if not quiet: |
68 | print ">>> ", "skipping fjr", f |