CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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__
 
def run
 
- Public Member Functions inherited from production_tasks.Task
def __init__
 
def addOption
 
def getname
 
def run
 

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 247 of file production_tasks.py.

Constructor & Destructor Documentation

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

Definition at line 249 of file production_tasks.py.

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

Member Function Documentation

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

Definition at line 251 of file production_tasks.py.

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

Member Data Documentation

production_tasks.CheckForWrite.user

Definition at line 253 of file production_tasks.py.

Referenced by cmsPerfSuite.PerfSuite.optionParse().