Functions | Variables
retire-remove-files Namespace Reference

Functions

def dropbox_path (pathname)
 
def locateAndRetire (filename)
 
def retireWithChildren (filename)
 

Variables

string usage = "usage: %prog [-n] [-c] [-d] <file_list>"
 
 parser = OptionParser(usage=usage)
 
 help
 
 default
 
 False
 
 action
 
 options
 
 args
 
 children
 
 samweb = samweb_client.SAMWebClient(experiment='nova')
 
 shell
 
 list_bad_files = open(args[0],'r')
 
 role
 
 filename = filename.strip()
 
 type
 
 str
 
 experiment
 

Function Documentation

def retire-remove-files.dropbox_path (   pathname)

Definition at line 72 of file retire-remove-files.py.

References parse_dependency_file_t.list.

Referenced by locateAndRetire().

72 def dropbox_path(pathname):
73  dirs = ['/pnfs/nova/scratch/fts/dropbox']
74  head, tail = os.path.split(pathname)
75  hash = md5.new(tail)
76  dirs += list(hash.hexdigest()[:3])
77  fullpath = os.path.join(*dirs)
78  return fullpath
79 
80 
def dropbox_path(pathname)
def retire-remove-files.locateAndRetire (   filename)
"
Locates the file in SAM and gets its Enstore location (path) and 
Bluearc path if it has one. It then retires the file and removes 
it from each of these locations.

Definition at line 81 of file retire-remove-files.py.

References dropbox_path().

Referenced by retireWithChildren().

81 def locateAndRetire(filename):
82  """"
83  Locates the file in SAM and gets its Enstore location (path) and
84  Bluearc path if it has one. It then retires the file and removes
85  it from each of these locations.
86  """
87  # Locate old file
88  location = samweb.locateFile(filename)
89  loc_size = len(location)
90 
91  paths = []
92 
93  for loc in location:
94 
95  this_path = loc["full_path"]
96  index = this_path.index(":")
97  this_path = this_path[index+1:len(this_path)]
98  paths.append(this_path)
99  if options.dropbox:
100  dropath = dropbox_path(filename.replace("log.bz2","root"))
101  if os.path.exists(os.path.join(dropath, filename)):
102  paths.append(dropath)
103 
104 
105  # Retire/remove file
106  try:
107  if not options.test:
108  # Retire file
109  samweb.retireFile(filename)
110  except:
111  print "Failed to retire the file"
112  raise
113 
114  try:
115  # Remove from /pnfs/ location
116  #print enstore_path
117  for path in paths:
118  bash_cd = ("cd %s") % path
119  bash_mv = ("rm -vf %s") % filename
120  bash_both = bash_cd+";"+bash_mv
121  print bash_both
122  if not options.test:
123  subprocess.Popen(bash_both,shell=True)
124  except:
125  print "Error: ", sys.exc_info()[0]
126  sys.exit(1)
127 
128  if options.test:
129  print "File " + filename + " would be retired and removed!"
130  else:
131  print "File " + filename + " retired and removed!"
132  print
133 
134 
135 
136 # Recursive function to retire a file
137 # and all of its children
def locateAndRetire(filename)
def dropbox_path(pathname)
def retire-remove-files.retireWithChildren (   filename)

Definition at line 138 of file retire-remove-files.py.

References locateAndRetire().

138 def retireWithChildren(filename):
139  if options.children:
140  children = samweb.getFileLineage("children",filename)
141  if not len(children):
142  print "No children of",filename
143 
144  else:
145  for child in children:
146  child_name = child["file_name"]
147  print "Located child file", child_name
148  retireWithChildren(child_name)
149 
150  locateAndRetire(filename)
151 
152 # Loop over the list of bad files
def locateAndRetire(filename)
def retireWithChildren(filename)

Variable Documentation

retire-remove-files.action

Definition at line 31 of file retire-remove-files.py.

retire-remove-files.args

Definition at line 35 of file retire-remove-files.py.

retire-remove-files.children

Definition at line 46 of file retire-remove-files.py.

Referenced by art::RootInputFile.fillAuxiliary().

retire-remove-files.default

Definition at line 31 of file retire-remove-files.py.

retire-remove-files.experiment

Definition at line 55 of file retire-remove-files.py.

retire-remove-files.False

Definition at line 31 of file retire-remove-files.py.

retire-remove-files.filename = filename.strip()

Definition at line 155 of file retire-remove-files.py.

retire-remove-files.help

Definition at line 31 of file retire-remove-files.py.

retire-remove-files.list_bad_files = open(args[0],'r')

Definition at line 66 of file retire-remove-files.py.

retire-remove-files.options

Definition at line 35 of file retire-remove-files.py.

retire-remove-files.parser = OptionParser(usage=usage)

Definition at line 30 of file retire-remove-files.py.

retire-remove-files.role
retire-remove-files.samweb = samweb_client.SAMWebClient(experiment='nova')

Definition at line 54 of file retire-remove-files.py.

retire-remove-files.shell

Definition at line 58 of file retire-remove-files.py.

retire-remove-files.str

Definition at line 32 of file retire-remove-files.py.

retire-remove-files.type

Definition at line 32 of file retire-remove-files.py.

retire-remove-files.usage = "usage: %prog [-n] [-c] [-d] <file_list>"

Definition at line 29 of file retire-remove-files.py.