ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CRAB/python/LFNBaseName.py
Revision: 1.23
Committed: Fri Jul 31 16:21:12 2009 UTC (15 years, 9 months ago) by fanzago
Content type: text/x-python
Branch: MAIN
CVS Tags: CRAB_2_6_3_pre5, CRAB_2_6_3_pre4, CRAB_2_6_3_pre3, CRAB_2_6_3_pre2, CRAB_2_7_0_pre2, CRAB_2_6_3_pre1, test_1, CRAB_2_7_0_pre1, CRAB_2_6_2, CRAB_2_6_2_pre2, CRAB_2_6_2_pre1
Branch point for: CRAB_2_6_X_br
Changes since 1.22: +46 -1 lines
Log Message:
changes related publication name too long, savannah task 10664

File Contents

# User Rev Content
1 afanfani 1.2 #!/usr/bin/env python
2     """
3     _LFNBaseName_
4     """
5    
6     from crab_exceptions import *
7 spiga 1.21 from crab_util import runCommand, getUserName
8 afanfani 1.2 import common
9 afanfani 1.12 import os, string, time
10 afanfani 1.2
11    
12 spiga 1.21 def LFNBase(forced_path, PrimaryDataset='',ProcessedDataset='',merged=True,publish=False):
13 afanfani 1.2 """
14     """
15 fanzago 1.10 if (PrimaryDataset == 'null'):
16     PrimaryDataset = ProcessedDataset
17 spiga 1.20 if PrimaryDataset != '':
18     if ( PrimaryDataset[0] == '/' ): PrimaryDataset=PrimaryDataset[1:]
19 spiga 1.21 lfnbase = os.path.join(forced_path, getUserName(), PrimaryDataset, ProcessedDataset)
20 fanzago 1.23 if (publish == True):
21     checkLength(lfnbase, forced_path, PrimaryDataset, ProcessedDataset)
22     return lfnbase
23 ewv 1.9
24 fanzago 1.23 def checkLength(lfnbase, forced_path, PrimaryDataset, ProcessedDataset):
25     """
26     """
27    
28     len_primary = len(PrimaryDataset)
29    
30     common.logger.debug("CheckLength of LFN and User DatasetName")
31     common.logger.debug("max length for complete LFN is 500 characters, max length for primary dataset is 100 characters")
32     common.logger.debug("PrimaryDataset = " + PrimaryDataset)
33     common.logger.debug("len_primary = " + str(len_primary))
34    
35     if (len_primary > 100):
36     raise CrabException("Warning: you required user_data_publication. The PrimaryDatasetName has to be < 100 characters")
37    
38     if (PrimaryDataset != ProcessedDataset):
39     common.logger.debug("ProcessedDataset = " + ProcessedDataset)
40     common.logger.debug("len(ProcessedDataset) = " + str(len(ProcessedDataset)))
41 afanfani 1.2
42 fanzago 1.23 common.logger.debug("forced_path = " + forced_path)
43     common.logger.debug("len(forced_path) = " + str(len(forced_path)))
44    
45     user = getUserName()
46     len_user_name = len(user)
47     common.logger.debug("user = " + user)
48     common.logger.debug("len_user_name = " + str(len_user_name))
49    
50     common.logger.debug("lfnbase = " + lfnbase)
51     common.logger.debug("len(lfnbase) = " + str(len(lfnbase)))
52    
53     ### we suppose a output_file_name of 50 characters ###
54     if len(lfnbase)>450:
55     if (PrimaryDataset != ProcessedDataset):
56     #500 - len_user_name - len_primary - len(forced) - len(PSETHASH = 32) - 4(/) - output(50)
57     #~400 - len_user_name - len_primary - len(forced)
58     if (len(ProcessedDataset) > (400 - len_user_name - len_primary - len(forced_path))):
59     raise CrabException("Warning: publication name too long. USER.publish_data_name has to be < " + str(400 - len_user_name - len_primary - len(forced_path)) + " characters")
60     else:
61     raise CrabException("Warning: LFN > 500 characters")
62     else:
63     if (len(ProcessedDataset) > (400 - len_user_name - len(forced_path)) / 2):
64     raise CrabException("Warning: publication name too long. USER.publish_data_name has to be < " + str((400 - len_user_name - len(forced_path)) / 2) + " characters")
65     else:
66     raise CrabException("Warning: LFN > 500 characters")
67    
68 afanfani 1.4
69 afanfani 1.2 if __name__ == '__main__' :
70     """
71     """
72 spiga 1.22 import logging
73     common.logger = logging
74 afanfani 1.2
75 ewv 1.9 print "xx %s xx"%getUserName()
76 afanfani 1.2 baselfn = LFNBase("datasetstring")
77 ewv 1.9 print baselfn
78 afanfani 1.2
79     unmergedlfn = LFNBase("datasetstring",merged=False)
80 ewv 1.9 print unmergedlfn
81 afanfani 1.2 print PFNportion("datasetstring")