Ejemplo n.º 1
0
 def splitEndpoint(self, endpoint):
     '''
     Return relevant infos from endpoint  
     '''
     SE = ''
     SE_PATH = ''
     USER = getUserName()
     if self.usePhedex: 
         ### FEDE PER TEST WITH XROOTD
         if (self.protocol == 'direct' or self.protocol == 'stageout'):
             SE = self.SE[self.sched]
             SE_PATH = endpoint 
             #############################   
             #print "    SE_PATH = ", SE_PATH
         else: 
             url = 'http://'+endpoint.split('://')[1]
             scheme, host, path, params, query, fragment = urlparse(url)
             SE = self.getAuthoritativeSE()
             SE_PATH = endpoint.split(host)[1]
     else:
         SE = self.node
         SE_PATH = self.user_se_path + self.user_remote_dir 
         if self.lfn.find('group') != -1:
             try:
                 USER = (self.lfn.split('group')[1]).split('/')[1]
             except:
                 pass
     return SE, SE_PATH, USER 
Ejemplo n.º 2
0
 def splitEndpoint(self, endpoint):
     '''
     Return relevant infos from endpoint  
     '''
     SE = ''
     SE_PATH = ''
     USER = getUserName()
     if self.usePhedex:
         ### FEDE PER TEST WITH XROOTD
         if (self.protocol == 'direct' or self.protocol == 'stageout'):
             SE = self.SE[self.sched]
             SE_PATH = endpoint
             #############################
             #print "    SE_PATH = ", SE_PATH
         else:
             url = 'http://' + endpoint.split('://')[1]
             scheme, host, path, params, query, fragment = urlparse(url)
             SE = self.getAuthoritativeSE()
             SE_PATH = endpoint.split(host)[1]
     else:
         SE = self.node
         SE_PATH = self.user_se_path + self.user_remote_dir
         if self.lfn.find('group') != -1:
             try:
                 USER = (self.lfn.split('group')[1]).split('/')[1]
             except:
                 pass
     return SE, SE_PATH, USER
Ejemplo n.º 3
0
def checkLength(lfnbase, forced_path, PrimaryDataset, ProcessedDataset):
    """
    """

    len_primary = len(PrimaryDataset)

    common.logger.debug("CheckLength of LFN and User DatasetName")
    common.logger.debug(
        "max length for complete LFN is 500 characters, max length for primary dataset is 100 characters"
    )
    common.logger.debug("PrimaryDataset = " + PrimaryDataset)
    common.logger.debug("len_primary = " + str(len_primary))

    if (len_primary > 100):
        raise CrabException(
            "Warning: you required user_data_publication. The PrimaryDatasetName has to be < 100 characters"
        )

    if (PrimaryDataset != ProcessedDataset):
        common.logger.debug("ProcessedDataset = " + ProcessedDataset)
        common.logger.debug("len(ProcessedDataset) = " +
                            str(len(ProcessedDataset)))

    common.logger.debug("forced_path = " + forced_path)
    common.logger.debug("len(forced_path) = " + str(len(forced_path)))

    user = getUserName()
    len_user_name = len(user)
    common.logger.debug("user = "******"len_user_name = " + str(len_user_name))

    common.logger.debug("lfnbase = " + lfnbase)
    common.logger.debug("len(lfnbase) = " + str(len(lfnbase)))

    ### we suppose a output_file_name of 50 characters ###
    if len(lfnbase) > 450:
        if (PrimaryDataset != ProcessedDataset):
            #500 - len_user_name - len_primary - len(forced) - len(PSETHASH = 32) - 4(/) - output(50)
            #~400 - len_user_name - len_primary - len(forced)
            if (len(ProcessedDataset) >
                (400 - len_user_name - len_primary - len(forced_path))):
                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")
            else:
                raise CrabException("Warning: LFN > 500 characters")
        else:
            if (len(ProcessedDataset) >
                (400 - len_user_name - len(forced_path)) / 2):
                raise CrabException(
                    "Warning: publication name too long. USER.publish_data_name has to be < "
                    + str((400 - len_user_name - len(forced_path)) / 2) +
                    " characters")
            else:
                raise CrabException("Warning: LFN > 500 characters")
Ejemplo n.º 4
0
def LFNBase(forced_path, PrimaryDataset='',ProcessedDataset='',merged=True,publish=False):
    """
    """
    if (PrimaryDataset == 'null'):
        PrimaryDataset = ProcessedDataset
    if PrimaryDataset != '':
        if ( PrimaryDataset[0] == '/' ):  PrimaryDataset=PrimaryDataset[1:]  
    if forced_path.find('store/group')>0:
        lfnbase = os.path.join(forced_path, PrimaryDataset, ProcessedDataset)
    else:
        lfnbase = os.path.join(forced_path, getUserName(), PrimaryDataset, ProcessedDataset)
    if (publish == True):
        checkSlash(ProcessedDataset)
        checkLength(lfnbase, forced_path, PrimaryDataset, ProcessedDataset)
    return lfnbase
Ejemplo n.º 5
0
def checkLength(lfnbase, forced_path, PrimaryDataset, ProcessedDataset):
    """
    """
    
    len_primary = len(PrimaryDataset)
    
    common.logger.debug("CheckLength of LFN and User DatasetName")
    common.logger.debug("max length for complete LFN is 500 characters, max length for primary dataset is 100 characters")
    common.logger.debug("PrimaryDataset = " + PrimaryDataset)
    common.logger.debug("len_primary = " + str(len_primary))

    if (len_primary > 100):
       raise CrabException("Warning: you required user_data_publication. The PrimaryDatasetName has to be < 100 characters")
    
    if (PrimaryDataset != ProcessedDataset):
        common.logger.debug("ProcessedDataset = " + ProcessedDataset)
        common.logger.debug("len(ProcessedDataset) = " + str(len(ProcessedDataset)))

    common.logger.debug("forced_path = " + forced_path)
    common.logger.debug("len(forced_path) = " + str(len(forced_path)))    
    
    user = getUserName()
    len_user_name = len(user)
    common.logger.debug("user = "******"len_user_name = " + str(len_user_name))
    
    common.logger.debug("lfnbase = " + lfnbase)
    common.logger.debug("len(lfnbase) = " + str(len(lfnbase)))
    
    ### we suppose a output_file_name of 50 characters ### 
    if len(lfnbase)>450:
        if (PrimaryDataset != ProcessedDataset):
            #500 - len_user_name - len_primary - len(forced) - len(PSETHASH = 32) - 4(/) - output(50)
            #~400 - len_user_name - len_primary - len(forced)
            if (len(ProcessedDataset) > (400 - len_user_name - len_primary - len(forced_path))):
                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")
            else:
                raise CrabException("Warning: LFN > 500 characters")
        else:
            if (len(ProcessedDataset) > (400 - len_user_name - len(forced_path)) / 2):
                raise CrabException("Warning: publication name too long. USER.publish_data_name has to be < " + str((400 - len_user_name - len(forced_path)) / 2) + " characters")
            else:
                raise CrabException("Warning: LFN > 500 characters")
Ejemplo n.º 6
0
def LFNBase(forced_path,
            PrimaryDataset='',
            ProcessedDataset='',
            merged=True,
            publish=False):
    """
    """
    if (PrimaryDataset == 'null'):
        PrimaryDataset = ProcessedDataset
    if PrimaryDataset != '':
        if (PrimaryDataset[0] == '/'): PrimaryDataset = PrimaryDataset[1:]
    if forced_path.find('store/group') > 0:
        lfnbase = os.path.join(forced_path, PrimaryDataset, ProcessedDataset)
    else:
        lfnbase = os.path.join(forced_path, getUserName(), PrimaryDataset,
                               ProcessedDataset)
    if (publish == True):
        checkSlash(ProcessedDataset)
        checkLength(lfnbase, forced_path, PrimaryDataset, ProcessedDataset)
    return lfnbase
Ejemplo n.º 7
0
                    "Warning: publication name too long. USER.publish_data_name has to be < "
                    +
                    str(400 - len_user_name - len_primary - len(forced_path)) +
                    " characters")
            else:
                raise CrabException("Warning: LFN > 500 characters")
        else:
            if (len(ProcessedDataset) >
                (400 - len_user_name - len(forced_path)) / 2):
                raise CrabException(
                    "Warning: publication name too long. USER.publish_data_name has to be < "
                    + str((400 - len_user_name - len(forced_path)) / 2) +
                    " characters")
            else:
                raise CrabException("Warning: LFN > 500 characters")


if __name__ == '__main__':
    """
    """
    import logging
    common.logger = logging

    print "xx %s xx" % getUserName()
    baselfn = LFNBase("datasetstring")
    print baselfn

    unmergedlfn = LFNBase("datasetstring", merged=False)
    print unmergedlfn
    print PFNportion("datasetstring")
Ejemplo n.º 8
0
    
    ### we suppose a output_file_name of 50 characters ### 
    if len(lfnbase)>450:
        if (PrimaryDataset != ProcessedDataset):
            #500 - len_user_name - len_primary - len(forced) - len(PSETHASH = 32) - 4(/) - output(50)
            #~400 - len_user_name - len_primary - len(forced)
            if (len(ProcessedDataset) > (400 - len_user_name - len_primary - len(forced_path))):
                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")
            else:
                raise CrabException("Warning: LFN > 500 characters")
        else:
            if (len(ProcessedDataset) > (400 - len_user_name - len(forced_path)) / 2):
                raise CrabException("Warning: publication name too long. USER.publish_data_name has to be < " + str((400 - len_user_name - len(forced_path)) / 2) + " characters")
            else:
                raise CrabException("Warning: LFN > 500 characters")
            

if __name__ == '__main__' :
    """
    """
    import logging 
    common.logger = logging

    print "xx %s xx"%getUserName()
    baselfn = LFNBase("datasetstring")
    print baselfn

    unmergedlfn = LFNBase("datasetstring",merged=False)
    print unmergedlfn
    print PFNportion("datasetstring")