3 from __future__
import print_function
4 import os, time, sys, shutil, glob, smtplib, re, subprocess
7 from datetime
import datetime
8 from email.MIMEText
import MIMEText
10 SOURCEDIR =
"/dqmdata/dqm/merged"
11 INJECTIONDIR =
"/dqmdata/dqm/Tier0Shipping/inject"
12 TRASHCAN =
"/dqmdata/dqm/trashcan"
13 HOSTNAME =
"srv-C2D05-19"
14 CONFIGFILE =
"/nfshome0/dqm/.transfer/myconfig.txt"
15 INJECTIONSCRIPT =
"/nfshome0/tier0/scripts/injectFileIntoTransferSystem.pl"
17 EMPTY_TRASHCAN =
False
24 for dir1, subdirs, files
in os.walk(SOURCEDIR):
27 version=int(f.split(
"_V")[-1][:4])
28 vlfn=f.split(
"_V")[0]+f.split(
"_V")[1][4:]
32 if vlfn
in newfiles.keys()
and version >= newfiles[vlfn][0]:
33 newfiles[vlfn]=(version,
"%s/%s" % (dir1,f))
34 elif vlfn
not in newfiles.keys():
35 newfiles[vlfn]=(version,
"%s/%s" % (dir1,f))
37 trashfiles.append(
"%s/%s" % (dir1,f))
39 return (newfiles,trashfiles)
42 fname=f.rsplit(
"/",1)[-1]
43 dname=f.rsplit(
"/",1)[0]
44 run=f.split(
"_R")[-1][:9]
45 iname=
"%s/%s" % (INJECTIONDIR,fname)
47 parameters=[
"--filename %s" % fname,
49 "--path %s" % INJECTIONDIR,
51 "--hostname %s" % HOSTNAME,
52 "--config %s" % CONFIGFILE,
53 "--runnumber %s" % run,
55 "--numevents 834474816",
56 "--appname dqmArchive",
57 "--appversion dqmArchive_1_0"]
58 cmd=
"%s %s" % (INJECTIONSCRIPT,
" ".
join(parameters))
59 result = subprocess.getstatusoutput(cmd)
62 print(
"Error injecting file %s to transfer system checking if it exists" % f)
63 chkparameters=[
"--check",
"--filename %s" % fname,
"--config %s" % CONFIGFILE]
64 cmd=
"%s %s" % (INJECTIONSCRIPT,
" ".
join(chkparameters))
65 result = subprocess.getstatusoutput(cmd)
67 if "File not found in database" in result[1]:
68 print(
"Error: file %s not found in transfer database, check configuration" % f)
71 print(
"Warning: file %s already exists in transfer database" % f)
74 print(
"Error: problem checking database entry for file %s\n Error:%s" % (f,result[1]))
77 print(
"File %s injected successfully" % f)
86 if not os.path.exists(TRASHCAN):
88 if not os.path.exists(INJECTIONDIR):
89 os.makedirs(INJECTIONDIR)
96 tfname=
"%s/%s" % (TRASHCAN,tf.rsplit(
"/",1)[-1])
97 shutil.move(tf,tfname)
100 for ver,f
in newfiles.values():
102 time.sleep(WAIT_TIMEt )
104 if __name__ ==
"__main__":
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)