CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 19 of file fileTransfer.py.

Referenced by transferFiles().

19 
20 def getFileLists():
21  newfiles={}
22  trashfiles=[]
23  filelist=[]
24  for dir1, subdirs, files in os.walk(SOURCEDIR):
25  for f in files:
26  try:
27  version=int(f.split("_V")[-1][:4])
28  vlfn=f.split("_V")[0]+f.split("_V")[1][4:]
29  except:
30  version=1
31  vlfn=f
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))
36  else:
37  trashfiles.append("%s/%s" % (dir1,f))
38 
39  return (newfiles,trashfiles)
#=====================================================================================
def fileTransfer.injectFile (   f,
  renotify = False 
)

Definition at line 40 of file fileTransfer.py.

References join().

Referenced by transferFiles().

40 
41 def injectFile(f,renotify=False):
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)
46  shutil.move(f,iname)
47  parameters=["--filename %s" % fname,
48  "--type dqm",
49  "--path %s" % INJECTIONDIR,
50  "--destination dqm",
51  "--hostname %s" % HOSTNAME,
52  "--config %s" % CONFIGFILE,
53  "--runnumber %s" % run,
54  "--lumisection 95",
55  "--numevents 834474816",
56  "--appname dqmArchive",
57  "--appversion dqmArchive_1_0"]
58  cmd="%s %s" % (INJECTIONSCRIPT," ".join(parameters))
59  result = commands.getstatusoutput(cmd)
60  if result[0] >= 1:
61  output = result[1]
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 = commands.getstatusoutput(cmd)
66  if result[0]==1:
67  if "File not found in database" in result[1]:
68  print "Error: file %s not found in transfer database, check configuration" % f
69  return 0
70  else:
71  print "Warning: file %s already exists in transfer database" % f
72  return 2
73  else:
74  print "Error: problem checking database entry for file %s\n Error:%s" % (f,result[1])
75  return 0
76  else:
77  print "File %s injected successfully" % f
78  return 1
#=====================================================================================
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def fileTransfer.transferFiles ( )

Definition at line 79 of file fileTransfer.py.

References getFileLists(), and injectFile().

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

Variable Documentation

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

Definition at line 13 of file fileTransfer.py.

fileTransfer.EMPTY_TRASHCAN = False

Definition at line 16 of file fileTransfer.py.

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

Definition at line 12 of file fileTransfer.py.

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

Definition at line 10 of file fileTransfer.py.

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

Definition at line 14 of file fileTransfer.py.

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

Definition at line 9 of file fileTransfer.py.

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

Definition at line 11 of file fileTransfer.py.

int fileTransfer.WAIT_TIME = 600

Definition at line 17 of file fileTransfer.py.