CMS 3D CMS Logo

castorBaseDir.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from __future__ import print_function
3 import os, sys
4 import eostools as castortools
5 
6 def getUserAndArea(user):
7  """Factor out the magic user hack for use in other classes"""
8 
9  area = 'user'
10 
11  tokens = user.split('_')
12  if tokens and len(tokens) > 1:
13  user = tokens[0]
14  area = tokens[1]
15  return user, area
16 
17 def castorBaseDir( user=os.environ['USER'], area = None):
18  """Gets the top level directory to use for writing for 'user'"""
19 
20  if area is None:
21  user, area = getUserAndArea(user)
22 
23  d = 'root://eoscms.cern.ch//eos/cms/store/cmst3/%s/%s/CMG' % (area,user)
24  exists = castortools.isDirectory( castortools.lfnToCastor(d) )
25  if exists:
26  return d
27  else:
28  msg = "The directory '%s' does not exist. Please check the username and area (user/group). You may need to create the directory yourself." % d
29  print(msg, file=sys.stderr)
30  raise NameError(msg)
31 
33  """Gets the top level directory to use for writing for the current user"""
34  return castorBaseDir()
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def castorBaseDir(user=os.environ['USER'], area=None)
def myCastorBaseDir()
def getUserAndArea(user)
Definition: castorBaseDir.py:6