ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/scripts/edmProvDiff
Revision: 1.1
Committed: Wed Aug 12 12:08:24 2009 UTC (15 years, 8 months ago) by hegner
Branch: MAIN
Log Message:
first commit of provenance handling code. still experimental

File Contents

# Content
1 #!/usr/bin/env python
2
3 # A script to compare the provenance of two input root files.
4 # It prints out informations about those modules which are common to the input files,
5 # but whose parameters are set to different values, and about those modules
6 # present only in one of the two files.
7 # According to the level of verbosity, it will be report the name of these modules
8 # and details about the parameters and their values.
9 #
10 # author: Annapaola de Cosa
11
12 from optparse import OptionParser
13 import sys
14 from subprocess import Popen, PIPE, STDOUT
15 from PhysicsTools.PythonAnalysis.read_provenance import *
16 from PhysicsTools.PythonAnalysis.diff_provenance import *
17
18
19 usage = "usage: %prog filename1 filename2"
20 parser = OptionParser(usage=usage, version="%prog 0.1")
21 parser.add_option("-v", "--verbosity_level", dest="verbose", help="[0] to print short message [1], to print details about the differences of modules common to both files, [2] to print all the details about the differences between the two files")
22 (options, args) = parser.parse_args()
23
24 # check whether all needed options are given
25 if len(args) != 2:
26 parser.print_help()
27 sys.exit()
28
29 def provenance(args):
30 cmd="edmProvDump "+args
31 if sys.platform == "linux2":
32 close_fds = True
33 else:
34 close_fds = False
35 pipe = Popen(cmd, bufsize=1,stdin=PIPE, stdout=PIPE, stderr=PIPE, shell = True, close_fds=close_fds)
36 provenance, provenanceerr=pipe.communicate()
37 s=args[:args.index('.')]
38 file=open(s,'w')
39 file.write(provenance)
40
41 return s
42
43 prov1=provenance(args[0])
44 prov2=provenance(args[1])
45 f=filereader()
46 module1=f.readfile(prov1)
47 module2=f.readfile(prov2)
48 d=difference(options.verbose)
49 d.module_diff(module1,module2,args[0],args[1])
50