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.1 by fanzago, Thu Mar 20 10:43:34 2008 UTC vs.
Revision 1.1.2.1 by fanzago, Thu Mar 20 10:43:34 2008 UTC

# Line 0 | Line 1
1 + #!/usr/bin/env python
2 + """
3 + _LFNBaseName_
4 + """
5 +
6 + from crab_exceptions import *
7 + from crab_util import runCommand
8 + import common
9 + import os, string
10 +
11 +
12 + def LFNBase(ProcessedDataset,merged=True):
13 +    """
14 +    """
15 +    lfnbase = "/store"
16 +    if not merged:
17 +     lfnbase = os.path.join(lfnbase,"tmp")
18 +    
19 +    lfnbase = os.path.join(lfnbase, "user", gethnUserName(), ProcessedDataset )
20 +    return lfnbase
21 +
22 + def PFNportion(ProcessedDataset):
23 +    pfnpath = os.path.join(gethnUserName(), ProcessedDataset )
24 +    return pfnpath
25 +
26 + def getDN():
27 +    """
28 +    extract DN from user proxy's identity
29 +    """
30 +    try:
31 +        userdn = runCommand("voms-proxy-info -identity")
32 +        userdn = string.strip(userdn)
33 +    except:
34 +        msg = "Error. Problem with voms-proxy-info -identity command"
35 +        raise CrabException(msg)
36 +    return userdn
37 +
38 + def gethnUserName():
39 +    """
40 +    extract user name from SiteDB
41 +    """
42 +    import urllib
43 +    hnUserName = None
44 +    userdn = getDN()
45 +    try:
46 +        sitedburl="https://cmsweb.cern.ch/sitedb/sitedb/json/index/dnUserName"
47 +        params = urllib.urlencode({'dn': userdn })
48 +        f = urllib.urlopen(sitedburl,params)
49 +        udata = f.read()
50 +        try:
51 +            userinfo= eval(udata)
52 +        except StandardError, ex:
53 +            msg = "Error. Problem extracting user name from %s : %s"%(sitedburl,ex)
54 +            raise CrabException(msg)
55 +        hnUserName = userinfo['user']
56 +    except:
57 +        msg = "Error. Problem extracting user name from %s"%sitedburl
58 +        msg += "Check that you are registered in SiteDB, see https://twiki.cern.ch/twiki/bin/view/CMS/SiteDBForCRAB"
59 +        raise CrabException(msg)
60 +    if not hnUserName:
61 +        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)
62 +        print msg
63 +        raise CrabException(msg)
64 +    return hnUserName
65 +
66 + if __name__ == '__main__' :
67 +    """
68 +    """
69 +    from crab_logger import Logger
70 +    from WorkSpace import *
71 +    continue_dir="/bohome/fanfani/CRAB"
72 +    cfg_params={'USER.logdir' : continue_dir }
73 +    common.work_space = WorkSpace(continue_dir, cfg_params)
74 +    log = Logger()
75 +    common.logger = log
76 +
77 +    baselfn = LFNBase("datasetstring")
78 +    print baselfn    
79 +
80 +    unmergedlfn = LFNBase("datasetstring",merged=False)
81 +    print unmergedlfn  
82 +    print PFNportion("datasetstring")

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines