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 73 of file retire-remove-files.py.

References parse_dependency_file_t.list.

Referenced by locateAndRetire().

73 def dropbox_path(pathname):
74  dirs = ['/pnfs/nova/scratch/fts/dropbox']
75  head, tail = os.path.split(pathname)
76  hash = md5.new(tail)
77  dirs += list(hash.hexdigest()[:3])
78  fullpath = os.path.join(*dirs)
79  return fullpath
80 
81 
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 82 of file retire-remove-files.py.

References dropbox_path(), and print.

Referenced by retireWithChildren().

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

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

References locateAndRetire(), and print.

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

Variable Documentation

retire-remove-files.action

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

retire-remove-files.args

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

retire-remove-files.children

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

retire-remove-files.default

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

retire-remove-files.experiment

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

retire-remove-files.False

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

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

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

retire-remove-files.help

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

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

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

retire-remove-files.options

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

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

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

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

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

retire-remove-files.shell

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

retire-remove-files.str

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

retire-remove-files.type

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

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

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