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