File indexing completed on 2024-11-25 02:29:50
0001
0002 import os, sys
0003 from . import eostools as castortools
0004
0005 def getUserAndArea(user):
0006 """Factor out the magic user hack for use in other classes"""
0007
0008 area = 'user'
0009
0010 tokens = user.split('_')
0011 if tokens and len(tokens) > 1:
0012 user = tokens[0]
0013 area = tokens[1]
0014 return user, area
0015
0016 def castorBaseDir( user=os.environ['USER'], area = None):
0017 """Gets the top level directory to use for writing for 'user'"""
0018
0019 if area is None:
0020 user, area = getUserAndArea(user)
0021
0022 d = 'root://eoscms.cern.ch//eos/cms/store/cmst3/%s/%s/CMG' % (area,user)
0023 exists = castortools.isDirectory( castortools.lfnToCastor(d) )
0024 if exists:
0025 return d
0026 else:
0027 msg = "The directory '%s' does not exist. Please check the username and area (user/group). You may need to create the directory yourself." % d
0028 print(msg, file=sys.stderr)
0029 raise NameError(msg)
0030
0031 def myCastorBaseDir():
0032 """Gets the top level directory to use for writing for the current user"""
0033 return castorBaseDir()