CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
production_tasks.CheckForWrite Class Reference
Inheritance diagram for production_tasks.CheckForWrite:
production_tasks.Task

Public Member Functions

def __init__ (self, dataset, user, options)
 
def run (self, input)
 
- Public Member Functions inherited from production_tasks.Task
def __init__ (self, name, dataset, user, options, instance=None)
 
def addOption (self, parser)
 
def getname (self)
 
def run (self, input)
 

Public Attributes

 user
 
- Public Attributes inherited from production_tasks.Task
 dataset
 
 instance
 
 name
 
 options
 
 user
 

Detailed Description

Checks whether you have write access to the CASTOR directory specified

Definition at line 251 of file production_tasks.py.

Constructor & Destructor Documentation

def production_tasks.CheckForWrite.__init__ (   self,
  dataset,
  user,
  options 
)

Definition at line 253 of file production_tasks.py.

253  def __init__(self, dataset, user, options):
254  Task.__init__(self,'CheckForWrite', dataset, user, options)
def __init__(self, dataset, user, options)

Member Function Documentation

def production_tasks.CheckForWrite.run (   self,
  input 
)
Check that the directory is writable

Definition at line 255 of file production_tasks.py.

255  def run(self, input):
256  """Check that the directory is writable"""
257  if self.user == 'CMS':
258  return {'Directory':None,'WriteAccess':True}
259  dir = input['FindOnCastor']['Directory']
260  if self.options.check:
261 
262  _, name = tempfile.mkstemp('.txt',text=True)
263  testFile = file(name,'w')
264  testFile.write('Test file')
265  testFile.close()
266 
267  store = castortools.castorToLFN(dir)
268  #this is bad, but castortools is giving me problems
269  if not os.system('cmsStage %s %s' % (name,store)):
270  fname = '%s/%s' % (dir,os.path.basename(name))
271  write = castortools.fileExists(fname)
272  if write:
273  castortools.rm(fname)
274  else:
275  raise Exception("Failed to write to directory '%s'" % dir)
276  os.remove(name)
277  return {'Directory':dir,'WriteAccess':True}

Member Data Documentation

production_tasks.CheckForWrite.user