예제 #1
0
    def testZipEncodeStr(self):
        """
        Test the zipEncodeStr function.
        """
        message = """
%MSG-s CMSException:  AfterFile 02-Jun-2010 14:31:43 CEST PostEndRun
cms::Exception caught in cmsRun
---- EventProcessorFailure BEGIN
EventProcessingStopped
---- ScheduleExecutionFailure BEGIN
ProcessingStopped
---- InvalidReference BEGIN
BadRefCore Attempt to dereference a RefCore containing an invalid
ProductID has been detected. Please modify the calling
code to test validity before dereferencing.
cms::Exception going through module PatMCMatching/analyzePatMCMatching run: 1 lumi: 666672 event: 305
---- InvalidReference END
Exception going through path p
---- ScheduleExecutionFailure END
an exception occurred during current event processing
cms::Exception caught in CMS.EventProcessor and rethrown
---- EventProcessorFailure END
"""
        encodedMessage = \
            'eNp1j8FqwzAMhu95Cl0G2yEhaXvyrU3dkkFHqfcCnq02hkQOtlz6+HM2MrbDdBLS9/1CxdNJHcsI7UnJh8GJnScBsL0yhoMbEOpV+ZqoXNVNDc1GrBuxWUMr1TucfWRJ9pKoMGMU4scHo9OtZ3C5G+O8L3OBvCPxOXiDMfpw0G5IAWEnj91b8Xvn6KbYTxPab0+ZHm0aUD7QpDn/r/qP1dFdD85e8IoBySz0Ts+j1md9y4zjxMAebGYWTsMCGE+sHeVk0JS/+Qqc79lkuNtDryN8IBLAc1VVL5+o0W8i'
        encodedMessage = encodeUnicodeToBytes(encodedMessage)
        self.assertEqual(zipEncodeStr(message, maxLen=300, compressLevel=9, steps=10, truncateIndicator=" (...)"),
                         encodedMessage)
        # Test different maximum lengths
        # Encoded message should always be less than the maximum limit.
        for maxLen in (800, 500, 20):
            self.assertLessEqual(
                    len(zipEncodeStr(message, maxLen=maxLen, compressLevel=9, steps=10, truncateIndicator=" (...)")),
                    maxLen)
예제 #2
0
    def testZipEncodeStr(self):
        """
        Test the zipEncodeStr function.
        """
        message = """
%MSG-s CMSException:  AfterFile 02-Jun-2010 14:31:43 CEST PostEndRun
cms::Exception caught in cmsRun
---- EventProcessorFailure BEGIN
EventProcessingStopped
---- ScheduleExecutionFailure BEGIN
ProcessingStopped
---- InvalidReference BEGIN
BadRefCore Attempt to dereference a RefCore containing an invalid
ProductID has been detected. Please modify the calling
code to test validity before dereferencing.
cms::Exception going through module PatMCMatching/analyzePatMCMatching run: 1 lumi: 666672 event: 305
---- InvalidReference END
Exception going through path p
---- ScheduleExecutionFailure END
an exception occurred during current event processing
cms::Exception caught in CMS.EventProcessor and rethrown
---- EventProcessorFailure END
"""
        encodedMessage = \
            'eNp1j8FqwzAMhu95Cl0G2yEhaXvyrU3dkkFHqfcCnq02hkQOtlz6+HM2MrbDdBLS9/1CxdNJHcsI7UnJh8GJnScBsL0yhoMbEOpV+ZqoXNVNDc1GrBuxWUMr1TucfWRJ9pKoMGMU4scHo9OtZ3C5G+O8L3OBvCPxOXiDMfpw0G5IAWEnj91b8Xvn6KbYTxPab0+ZHm0aUD7QpDn/r/qP1dFdD85e8IoBySz0Ts+j1md9y4zjxMAebGYWTsMCGE+sHeVk0JS/+Qqc79lkuNtDryN8IBLAc1VVL5+o0W8i'
        self.assertEqual(zipEncodeStr(message, maxLen=300, compressLevel=9, steps=10, truncateIndicator=" (...)"), encodedMessage)
        # Test different maximum lengths
        # Encoded message should always be less than the maximum limit.
        for maxLen in (800, 500, 20):
            self.assertLessEqual(len(zipEncodeStr(message, maxLen=maxLen, compressLevel=9, steps=10, truncateIndicator=" (...)")), maxLen)
예제 #3
0
    def setCondorChirpAttrDelayed(self, key, value, compress=False, maxLen=5120):
        """
        _setCondorChirpAttrDelayed_

        Util to call condor_chirp and publish the key/value pair

        """
        if compress:
            value = zipEncodeStr(value, maxLen=maxLen)

        # construct condor_chirp binary location from CONDOR_CONFIG
        # Note: This works when we do not use containers.
        condor_chirp_bin = None
        condor_config = os.getenv('CONDOR_CONFIG', None)
        if condor_config:
            condor_config_dir = os.path.dirname(condor_config)
            condor_chirp_bin = os.path.join(condor_config_dir, 'main/condor/libexec/condor_chirp')

        # If the above fails, look for the executable in the environment
        # This is the usual case for containers
        if not condor_chirp_bin or not os.path.isfile(condor_chirp_bin):
            condor_chirp_bin = getFullPath("condor_chirp")

        if condor_chirp_bin and os.access(condor_chirp_bin, os.X_OK):
            args = [condor_chirp_bin, 'set_job_attr_delayed', key, json.dumps(value)]
            subprocess.call(args)
        else:
            if condor_chirp_bin and not os.access(condor_chirp_bin, os.X_OK):
                msg = 'condor_chirp was found in: %s, but it was not an executable.' % condor_chirp_bin
            else:
                msg = 'condor_chirp was not found in the system.'
            self.logger.warning(msg)

        return
예제 #4
0
파일: Executor.py 프로젝트: dmwm/WMCore
    def setCondorChirpAttrDelayed(self, key, value, compress=False, maxLen=5120):
        """
        _setCondorChirpAttrDelayed_

        Util to call condor_chirp and publish the key/value pair

        """
        if compress:
            value = zipEncodeStr(value, maxLen=maxLen)

        # construct condor_chirp binary location from CONDOR_CONFIG
        condor_chirp_bin = None
        condor_config = os.getenv('CONDOR_CONFIG', None)
        if condor_config:
            condor_config_dir = os.path.dirname(condor_config)
            condor_chirp_bin = os.path.join(condor_config_dir, 'main/condor/libexec/condor_chirp')
            if not os.path.isfile(condor_chirp_bin):
                # Singularity container might not have CONDOR_CONFIG env.
                #TODO: It should have fixed from Singularity setting
                condor_chirp_bin = getFullPath("condor_chirp")

        if condor_chirp_bin and os.access(condor_chirp_bin, os.X_OK):
            args = [condor_chirp_bin, 'set_job_attr_delayed', key, json.dumps(value)]
            subprocess.call(args)

        return
예제 #5
0
    def setCondorChirpAttrDelayed(self,
                                  key,
                                  value,
                                  compress=False,
                                  maxLen=5120):
        """
        _setCondorChirpAttrDelayed_

        Util to call condor_chirp and publish the key/value pair

        """
        if compress:
            value = zipEncodeStr(value, maxLen=maxLen)

        # construct condor_chirp binary location from CONDOR_CONFIG
        condor_chirp_bin = None
        condor_config = os.getenv('CONDOR_CONFIG', None)
        if condor_config:
            condor_config_dir = os.path.dirname(condor_config)
            condor_chirp_bin = os.path.join(
                condor_config_dir, 'main/condor/libexec/condor_chirp')
            if not os.path.isfile(condor_chirp_bin):
                # Singularity container might not have CONDOR_CONFIG env.
                #TODO: It should have fixed from Singularity setting
                condor_chirp_bin = getFullPath("condor_chirp")

        if condor_chirp_bin and os.access(condor_chirp_bin, os.X_OK):
            args = [
                condor_chirp_bin, 'set_job_attr_delayed', key,
                json.dumps(value)
            ]
            subprocess.call(args)

        return