ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/CMSSW/PhysicsTools/PythonAnalysis/scripts/edmProvDiff
Revision: 1.2
Committed: Wed Oct 7 13:28:42 2009 UTC (15 years, 6 months ago) by decosa
Branch: MAIN
CVS Tags: V00-03-00
Changes since 1.1: +11 -10 lines
Log Message:
Provenance handling code. Version to test

File Contents

# User Rev Content
1 hegner 1.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 decosa 1.2 # but whose parameters are setted to different values, and about those modules
6 hegner 1.1 # 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 decosa 1.2 from readProv import *
16     from diffProv import *
17 hegner 1.1
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     if len(args) != 2:
25 decosa 1.2 print 'Incorrect usage'
26    
27 hegner 1.1 def provenance(args):
28     cmd="edmProvDump "+args
29     if sys.platform == "linux2":
30     close_fds = True
31     else:
32     close_fds = False
33     pipe = Popen(cmd, bufsize=1,stdin=PIPE, stdout=PIPE, stderr=PIPE, shell = True, close_fds=close_fds)
34     provenance, provenanceerr=pipe.communicate()
35     s=args[:args.index('.')]
36     file=open(s,'w')
37     file.write(provenance)
38    
39     return s
40 decosa 1.2 try:
41     prov1=provenance(args[0])
42     prov2=provenance(args[1])
43     except IndexError:
44     print "Specify input file names\nType 'edmProvDiff -h' to visualize the arguments needed"
45 hegner 1.1 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    
51 decosa 1.2