File indexing completed on 2024-11-26 02:34:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 import os, sys, datetime, shutil, optparse
0027
0028
0029
0030
0031
0032
0033 def mysystem(command,apply=1):
0034 print(command)
0035 if apply==1: return os.system(command)
0036 elif apply==0: return 0
0037 else:
0038 print('[electronStore.py] UNSUPPORTED ARGUMENT VALUE FOR mysystem(,apply):',apply)
0039 exit(1)
0040
0041
0042
0043
0044
0045
0046 class flushfile(object):
0047 def __init__(self,f):
0048 self.f = f
0049 def write(self,x):
0050 self.f.write(x)
0051 self.f.flush()
0052
0053 sys.stdout = flushfile(sys.stdout)
0054
0055
0056
0057
0058
0059
0060 if __name__ == "__main__":
0061
0062
0063
0064
0065
0066
0067 parser = optparse.OptionParser()
0068 parser.add_option("-f", "--force", dest="force", action="store_true", default=False,
0069 help="force the copy, even if the destination file already exists.")
0070 parser.add_option("-r", "--release", dest="release", action="store", default="current",
0071 help="release name of this set of histograms.")
0072 parser.add_option("-m", "--message", dest="message", action="store", default="",
0073 help="specific comment about this set of histograms")
0074 parser.add_option("-a", "--analyzers", dest="analyzers", action="store", default="",
0075 help="slash separated list of analyzers")
0076 parser.add_option("-c", "--configs", dest="configs", action="store", default="",
0077 help="slash separated list of cmsRun configurations")
0078 (options, args) = parser.parse_args()
0079
0080 if len(args)<2:
0081 print("[electronStore.py] I NEED AT LEAST TWO ARGUMENTS.")
0082 exit(2)
0083 store_file = args.pop(0)
0084 store_dir = args.pop()
0085 if len(args)>0: store_logs = ' '.join(args)
0086 else: store_logs = ''
0087
0088 analyzers = options.analyzers.split('/') ;
0089 configs = options.configs.split('/') ;
0090
0091
0092
0093
0094
0095
0096 if os.path.exists(store_dir)==False:
0097 os.makedirs(store_dir)
0098
0099
0100
0101
0102
0103
0104 if os.path.isfile(store_file)==True :
0105 print("STORE_FILE =",store_file)
0106 else :
0107 print("[electronStore.py] FILE DOES NOT EXIST :",store_file)
0108 exit(3)
0109
0110 if ( store_logs != '' ) :
0111 print("STORE_LOGS =",store_logs)
0112
0113
0114
0115
0116
0117
0118 output_file = store_dir+'/'+store_file
0119 if ( options.force==False and os.path.isfile(output_file)==True ) :
0120 print("[electronStore.py] ERROR: "+store_file+" ALREADY STORED IN "+store_dir+" !")
0121 exit(4)
0122
0123
0124
0125
0126
0127
0128 files = [ store_file ]
0129 for analyzer in analyzers:
0130 files.append('../plugins/'+analyzer+'.h')
0131 files.append('../plugins/'+analyzer+'.cc')
0132 for config in configs:
0133 files.append(config+'.py')
0134
0135 mysystem('cp '+' '.join(files)+' '+store_dir)
0136
0137 if ( store_logs != '' ) :
0138 mysystem('cp '+store_logs+' '+store_dir)
0139 mysystem('cd '+store_dir+' && gzip -f *.olog')
0140
0141
0142
0143
0144
0145
0146 store_url = store_dir.replace('/afs/cern.ch/cms/','http://cmsdoc.cern.ch/',1)
0147
0148 links = []
0149 for analyzer in analyzers:
0150 links.append('<a href="'+store_url+'/'+analyzer+'.h">'+analyzer+'.h</a>')
0151 links.append('<a href="'+store_url+'/'+analyzer+'.cc">'+analyzer+'.cc</a>')
0152 for config in configs:
0153 links.append('<a href="'+store_url+'/'+config+'.py">'+config+'.py</a>')
0154
0155 comment_file = open(store_dir+'/'+store_file+'.comment','w')
0156 print('The <a href="'+store_url+'/'+store_file+'">'+options.release+' histograms</a>', end=' ', file=comment_file)
0157 if (options.message!=''):
0158 print(' ('+options.message+')', end=' ', file=comment_file)
0159 print(' have been prepared with those analyzers and configurations: '+', '.join(links)+'.', end=' ', file=comment_file)
0160 print(file=comment_file)
0161 comment_file.close()
0162
0163
0164
0165
0166
0167
0168 exit(0)
0169
0170