CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
fileTransfer Namespace Reference

Functions

def getFileLists
 
def injectFile
 
def transferFiles
 

Variables

string CONFIGFILE = "/nfshome0/dqm/.transfer/myconfig.txt"
 
 EMPTY_TRASHCAN = False
 
string HOSTNAME = "srv-C2D05-19"
 
string INJECTIONDIR = "/dqmdata/dqm/Tier0Shipping/inject"
 
string INJECTIONSCRIPT = "/nfshome0/tier0/scripts/injectFileIntoTransferSystem.pl"
 
string SOURCEDIR = "/dqmdata/dqm/merged"
 
string TRASHCAN = "/dqmdata/dqm/trashcan"
 
int WAIT_TIME = 600
 

Function Documentation

def fileTransfer.getFileLists ( )

Definition at line 20 of file fileTransfer.py.

Referenced by transferFiles().

20 
21 def getFileLists():
22  newfiles={}
23  trashfiles=[]
24  filelist=[]
25  for dir1, subdirs, files in os.walk(SOURCEDIR):
26  for f in files:
27  try:
28  version=int(f.split("_V")[-1][:4])
29  vlfn=f.split("_V")[0]+f.split("_V")[1][4:]
30  except:
31  version=1
32  vlfn=f
33  if vlfn in newfiles.keys() and version >= newfiles[vlfn][0]:
34  newfiles[vlfn]=(version,"%s/%s" % (dir1,f))
35  elif vlfn not in newfiles.keys():
36  newfiles[vlfn]=(version,"%s/%s" % (dir1,f))
37  else:
38  trashfiles.append("%s/%s" % (dir1,f))
39 
40  return (newfiles,trashfiles)
#=====================================================================================
def fileTransfer.injectFile (   f,
  renotify = False 
)

Definition at line 41 of file fileTransfer.py.

References join(), and print().

Referenced by transferFiles().

41 
42 def injectFile(f,renotify=False):
43  fname=f.rsplit("/",1)[-1]
44  dname=f.rsplit("/",1)[0]
45  run=f.split("_R")[-1][:9]
46  iname="%s/%s" % (INJECTIONDIR,fname)
47  shutil.move(f,iname)
48  parameters=["--filename %s" % fname,
49  "--type dqm",
50  "--path %s" % INJECTIONDIR,
51  "--destination dqm",
52  "--hostname %s" % HOSTNAME,
53  "--config %s" % CONFIGFILE,
54  "--runnumber %s" % run,
55  "--lumisection 95",
56  "--numevents 834474816",
57  "--appname dqmArchive",
58  "--appversion dqmArchive_1_0"]
59  cmd="%s %s" % (INJECTIONSCRIPT," ".join(parameters))
60  result = subprocess.getstatusoutput(cmd)
61  if result[0] >= 1:
62  output = result[1]
63  print("Error injecting file %s to transfer system checking if it exists" % f)
64  chkparameters=["--check","--filename %s" % fname,"--config %s" % CONFIGFILE]
65  cmd="%s %s" % (INJECTIONSCRIPT," ".join(chkparameters))
66  result = subprocess.getstatusoutput(cmd)
67  if result[0]==1:
68  if "File not found in database" in result[1]:
69  print("Error: file %s not found in transfer database, check configuration" % f)
70  return 0
71  else:
72  print("Warning: file %s already exists in transfer database" % f)
73  return 2
74  else:
75  print("Error: problem checking database entry for file %s\n Error:%s" % (f,result[1]))
76  return 0
77  else:
78  print("File %s injected successfully" % f)
79  return 1
#=====================================================================================
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
static std::string join(char **cmd)
Definition: RemoteFile.cc:19
def fileTransfer.transferFiles ( )

Definition at line 80 of file fileTransfer.py.

References getFileLists(), and injectFile().

80 
81 def transferFiles():
82  while True:
83  #look for NEW files in SOURCEDIR and files that need to be cleared.
84  newfiles,trashfiles=getFileLists()
85 
86  #Making sure destination directories exist
87  if not os.path.exists(TRASHCAN):
88  os.makedirs(TRASHCAN)
89  if not os.path.exists(INJECTIONDIR):
90  os.makedirs(INJECTIONDIR)
91 
92  #Dealing with trash can
93  for tf in trashfiles:
94  if EMPTY_TRASHCAN:
95  os.remove(tf)
96  else:
97  tfname="%s/%s" % (TRASHCAN,tf.rsplit("/",1)[-1])
98  shutil.move(tf,tfname)
99 
100  #Down to bussines
101  for ver,f in newfiles.values():
102  ifr=injectFile(f)
103  time.sleep(WAIT_TIMEt )
#=====================================================================================

Variable Documentation

string fileTransfer.CONFIGFILE = "/nfshome0/dqm/.transfer/myconfig.txt"

Definition at line 14 of file fileTransfer.py.

fileTransfer.EMPTY_TRASHCAN = False

Definition at line 17 of file fileTransfer.py.

string fileTransfer.HOSTNAME = "srv-C2D05-19"

Definition at line 13 of file fileTransfer.py.

string fileTransfer.INJECTIONDIR = "/dqmdata/dqm/Tier0Shipping/inject"

Definition at line 11 of file fileTransfer.py.

string fileTransfer.INJECTIONSCRIPT = "/nfshome0/tier0/scripts/injectFileIntoTransferSystem.pl"

Definition at line 15 of file fileTransfer.py.

string fileTransfer.SOURCEDIR = "/dqmdata/dqm/merged"

Definition at line 10 of file fileTransfer.py.

string fileTransfer.TRASHCAN = "/dqmdata/dqm/trashcan"

Definition at line 12 of file fileTransfer.py.

int fileTransfer.WAIT_TIME = 600

Definition at line 18 of file fileTransfer.py.