CMS 3D CMS Logo

Functions
fileTransfer Namespace Reference

Functions

def getFileLists ()
 
def injectFile (f, renotify=False)
 
def transferFiles ()
 

Function Documentation

def fileTransfer.getFileLists ( )

Definition at line 19 of file fileTransfer.py.

References createfilelist.int.

Referenced by transferFiles().

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

Definition at line 40 of file fileTransfer.py.

References join().

Referenced by transferFiles().

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

Definition at line 79 of file fileTransfer.py.

References getFileLists(), and injectFile().

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