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