ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/LFNBaseName.py
(Generate patch)

Comparing COMP/CRAB/python/LFNBaseName.py (file contents):
Revision 1.8 by spiga, Thu Jun 5 13:39:32 2008 UTC vs.
Revision 1.9 by ewv, Tue Jul 8 19:34:00 2008 UTC

# Line 7 | Line 7 | from crab_exceptions import *
7   from crab_util import runCommand
8   import common
9   import os, string
10 + from ProdCommon.SiteDB.SiteDB import SiteDBJSON
11  
12  
13   def LFNBase(ProcessedDataset,merged=True,LocalUser=False):
14      """
15      """
16 <    lfnbase = "/store"
16 >    lfnbase = "/store"
17      if not merged:
18 <        lfnbase = os.path.join(lfnbase,"tmp")  
18 >        lfnbase = os.path.join(lfnbase,"tmp")
19      lfnbase = os.path.join(lfnbase, "user", getUserName(LocalUser=LocalUser), ProcessedDataset )
20 <      
20 >
21      return lfnbase
22  
23   def PFNportion(ProcessedDataset,LocalUser=False):
# Line 47 | Line 48 | def getDN():
48      except:
49          msg = "Error. Problem with voms-proxy-info -identity command"
50          raise CrabException(msg)
51 <    return userdn.split('\n')[0]
51 >    return userdn.split('\n')[0]
52  
53   def gethnUserName():
54      """
55      extract user name from SiteDB
56      """
56    import urllib
57      hnUserName = None
58      userdn = getDN()
59 +    mySiteDB = SiteDBJSON()
60 +
61      try:
62 <        sitedburl="https://cmsweb.cern.ch/sitedb/sitedb/json/index/dnUserName"
61 <        params = urllib.urlencode({'dn': userdn })
62 <        f = urllib.urlopen(sitedburl,params)
63 <        udata = f.read()
64 <        try:
65 <            userinfo= eval(udata)
66 <        except StandardError, ex:
67 <            msg = "Error. Problem extracting user name from %s : %s \n SiteDB call output: \n %s"%(sitedburl,ex,udata)
68 <            raise CrabException(msg)
69 <        hnUserName = userinfo['user']
62 >        hnUserName = mySiteDB.dnUserName(dn=userdn)
63      except:
64 <        msg = "Error. Problem extracting user name from %s "%sitedburl
65 <        msg += "\n Check that you are registered in SiteDB, see https://twiki.cern.ch/twiki/bin/view/CMS/SiteDBForCRAB"
73 <        msg += "\n SiteDB call output: \n %s"%udata
64 >        msg = "Error. Problem extracting user name from SiteDB"
65 >        msg += "\n Check that you are registered in SiteDB, see https://twiki.cern.ch/twiki/bin/view/CMS/SiteDBForCRAB"
66          raise CrabException(msg)
67      if not hnUserName:
68 <        msg = "Error. There is no user name associated to DN %s in %s. You need to register in SiteDB with the instructions at https://twiki.cern.ch/twiki/bin/view/CMS/SiteDBForCRAB"%(userdn,sitedburl)
68 >        msg = "Error. There is no user name associated to DN %s in SiteDB. You need to register in SiteDB with the instructions at https://twiki.cern.ch/twiki/bin/view/CMS/SiteDBForCRAB" % userdn
69          print msg
70          raise CrabException(msg)
71      return hnUserName
# Line 86 | Line 78 | def getUserName(LocalUser=False):
78         common.logger.message("==> Using as username the Unix user name")
79         UserName=getUnixUserName()
80         return UserName
81 <    
81 >
82      UserName=gethnUserName()
83      return UserName
84  
# Line 95 | Line 87 | if __name__ == '__main__' :
87      """
88      from crab_logger import Logger
89      from WorkSpace import *
90 <    continue_dir="/afs/cern.ch/user/a/afanfani/"
90 >    continue_dir = os.path.expanduser("~")
91      cfg_params={'USER.logdir' : continue_dir }
92      common.work_space = WorkSpace(continue_dir, cfg_params)
93      log = Logger()
94      common.logger = log
95  
96 <    print "xx %s xx"%getUserName()
96 >    print "xx %s xx"%getUserName()
97      baselfn = LFNBase("datasetstring")
98 <    print baselfn    
98 >    print baselfn
99  
100      unmergedlfn = LFNBase("datasetstring",merged=False)
101 <    print unmergedlfn  
101 >    print unmergedlfn
102      print PFNportion("datasetstring")

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines