Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /PhysicsTools/PythonAnalysis/scripts/edmProvDiff is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env python3
0002 
0003 # A script to compare the provenance of two input root files.
0004 # It prints out informations about those modules which are common to the input files,
0005 # but whose parameters are setted to different values, and about those modules
0006 # present only in one of the two files.
0007 # According to the level of verbosity, it will be report the name of these modules
0008 # and details about the parameters and their values.
0009 #
0010 # author:  Annapaola de Cosa
0011 
0012 from argparse import ArgumentParser
0013 import sys
0014 from subprocess import Popen, PIPE, STDOUT
0015 from PhysicsTools.PythonAnalysis.readProv import *
0016 from PhysicsTools.PythonAnalysis.diffProv import *
0017 
0018 parser = ArgumentParser()
0019 parser.add_argument('--version', action='version', version='%(prog)s 0.1')
0020 parser.add_argument("-v", "--verbosity_level", dest="verbose", choices=(0,1,2), 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")
0021 parser.add_argument("filename1",type=str)
0022 parser.add_argument("filename2",type=str)
0023 options = parser.parse_args()
0024 
0025 def provenance(args):
0026     cmd="edmProvDump "+args    
0027     if sys.platform == "linux2":
0028         close_fds = True
0029     else:
0030         close_fds = False  
0031     pipe = Popen(cmd, bufsize=1,stdin=PIPE, stdout=PIPE, stderr=PIPE, shell = True, close_fds=close_fds)
0032     provenance, provenanceerr=pipe.communicate()
0033     s=args[:args.index('.')]
0034     file=open(s,'w')    
0035     file.write(provenance)
0036 
0037     return s
0038 
0039 prov1=provenance(options.filename1)
0040 prov2=provenance(options.filename2)
0041 f=filereader()
0042 module1=f.readfile(prov1)
0043 module2=f.readfile(prov2)
0044 d=difference(options.verbose)
0045 d.module_diff(module1,module2,options.filename1,options.filename2)