26 import os, sys, datetime, shutil, optparse
35 if apply==1:
return os.system(command)
36 elif apply==0:
return 0
38 print '[electronStore.py] UNSUPPORTED ARGUMENT VALUE FOR mysystem(,apply):',apply
60 if __name__ ==
"__main__":
67 parser = optparse.OptionParser()
68 parser.add_option(
"-f",
"--force", dest=
"force", action=
"store_true", default=
False,
69 help=
"force the copy, even if the destination file already exists.")
70 parser.add_option(
"-r",
"--release", dest=
"release", action=
"store", default=
"current",
71 help=
"release name of this set of histograms.")
72 parser.add_option(
"-m",
"--message", dest=
"message", action=
"store", default=
"",
73 help=
"specific comment about this set of histograms")
74 parser.add_option(
"-a",
"--analyzers", dest=
"analyzers", action=
"store", default=
"",
75 help=
"slash separated list of analyzers")
76 parser.add_option(
"-c",
"--configs", dest=
"configs", action=
"store", default=
"",
77 help=
"slash separated list of cmsRun configurations")
78 (options, args) = parser.parse_args()
81 print "[electronStore.py] I NEED AT LEAST TWO ARGUMENTS." 83 store_file = args.pop(0)
84 store_dir = args.pop()
85 if len(args)>0: store_logs =
' '.
join(args)
88 analyzers = options.analyzers.split(
'/') ;
89 configs = options.configs.split(
'/') ;
96 if os.path.exists(store_dir)==
False:
97 os.makedirs(store_dir)
104 if os.path.isfile(store_file)==
True :
105 print "STORE_FILE =",store_file
107 print "[electronStore.py] FILE DOES NOT EXIST :",store_file
110 if ( store_logs !=
'' ) :
111 print "STORE_LOGS =",store_logs
118 output_file = store_dir+
'/'+store_file
119 if ( options.force==
False and os.path.isfile(output_file)==
True ) :
120 print "[electronStore.py] ERROR: "+store_file+
" ALREADY STORED IN "+store_dir+
" !" 128 files = [ store_file ]
129 for analyzer
in analyzers:
130 files.append(
'../plugins/'+analyzer+
'.h')
131 files.append(
'../plugins/'+analyzer+
'.cc')
132 for config
in configs:
133 files.append(config+
'.py')
137 if ( store_logs !=
'' ) :
138 mysystem(
'cp '+store_logs+
' '+store_dir)
139 mysystem(
'cd '+store_dir+
' && gzip -f *.olog')
146 store_url = store_dir.replace(
'/afs/cern.ch/cms/',
'http://cmsdoc.cern.ch/',1)
149 for analyzer
in analyzers:
150 links.append(
'<a href="'+store_url+
'/'+analyzer+
'.h">'+analyzer+
'.h</a>')
151 links.append(
'<a href="'+store_url+
'/'+analyzer+
'.cc">'+analyzer+
'.cc</a>')
152 for config
in configs:
153 links.append(
'<a href="'+store_url+
'/'+config+
'.py">'+config+
'.py</a>')
155 comment_file = open(store_dir+
'/'+store_file+
'.comment',
'w')
156 print >>comment_file,
'The <a href="'+store_url+
'/'+store_file+
'">'+options.release+
' histograms</a>',
157 if (options.message!=
''):
158 print >>comment_file,
' ('+options.message+
')',
159 print >>comment_file,
' have been prepared with those analyzers and configurations: '+
', '.
join(links)+
'.',
def mysystem(command, apply=1)
static std::string join(char **cmd)