Esempio n. 1
0
 def setUp( self ):
   self.testFile = 'UUID_to_store'
   self.testCfgFile = 'TestPilotLogger.cfg'
   getUniqueIDAndSaveToFile( self.testFile )
   self.logger = PilotLogger(self.testCfgFile)
   self.badFile = '////'
   self.nonExistentFile = 'abrakadabraToCzaryIMagia'
Esempio n. 2
0
 def setUp(self):
     self.testFile = 'UUID_to_store'
     self.testCfgFile = 'TestPilotLogger.cfg'
     getUniqueIDAndSaveToFile(self.testFile)
     self.logger = PilotLogger(self.testCfgFile)
     self.badFile = '////'
     self.nonExistentFile = 'abrakadabraToCzaryIMagia'
Esempio n. 3
0
    def __init__(
        self,
        configFile="pilot.json",
        messageSenderType="LOCAL_FILE",
        localOutputFile="myLocalQueueOfMessages",
        fileWithUUID="PilotUUID",
        setup="DIRAC-Certification",
    ):
        """ctr loads the configuration parameters from the json file
            or if the file does not exists, loads the default set
            of values. Next, if self.fileWithUUID is not set (this
            variable corresponds to the name of the file with Pilot
            Agent ID) the default value is used, and if the file does
            not exist, the Pilot ID is created and saved in this file.
        Args:
          configFile(str): Name of the file with the configuration parameters.
          messageSenderType(str): Type of the message sender to use e.g. to a REST interface,
            to a message queue or to a local file.
          localOutputFile(str): Name of the file that can be used to store the log messages locally.
          fileWithUUID(str): Name of the file used to store the Pilot identifier.
        """
        logging.debug("In init of PilotLogger")
        self.STATUSES = PilotLogger.STATUSES

        self.params = addMissingConfiguration(
            config=readPilotJSONConfigFile(configFile, setup),
            defaultConfig={
                "LoggingType": messageSenderType,
                "LocalOutputFile": localOutputFile,
                "FileWithID": fileWithUUID,
            },
        )

        fileWithID = self.params["FileWithID"]
        if os.path.isfile(fileWithID):
            logging.warning(
                "The file: " + fileWithID +
                " already exists. The content will be used to get UUID.")
        else:
            result = getUniqueIDAndSaveToFile(filename=fileWithID)
            if not result:
                logging.error("Error while generating pilot logger id.")
        self.messageSender = messageSenderFactory(
            senderType=self.params["LoggingType"], params=self.params)
        if not self.messageSender:
            logging.error("Something went wrong - no messageSender created.")
Esempio n. 4
0
    def __init__(self,
                 configFile='pilot.json',
                 messageSenderType='LOCAL_FILE',
                 localOutputFile='myLocalQueueOfMessages',
                 fileWithUUID='PilotUUID',
                 setup='DIRAC-Certification'):
        """ ctr loads the configuration parameters from the json file
        or if the file does not exists, loads the default set
        of values. Next, if self.fileWithUUID is not set (this
        variable corresponds to the name of the file with Pilot
        Agent ID) the default value is used, and if the file does
        not exist, the Pilot ID is created and saved in this file.
    Args:
      configFile(str): Name of the file with the configuration parameters.
      messageSenderType(str): Type of the message sender to use e.g. to a REST interface,
        to a message queue or to a local file.
      localOutputFile(str): Name of the file that can be used to store the log messages locally.
      fileWithUUID(str): Name of the file used to store the Pilot identifier.
    """
        self.STATUSES = PilotLogger.STATUSES

        self.params = addMissingConfiguration(
            config=readPilotJSONConfigFile(configFile, setup),
            defaultConfig={
                'LoggingType': messageSenderType,
                'LocalOutputFile': localOutputFile,
                'FileWithID': fileWithUUID
            })

        fileWithID = self.params['FileWithID']
        if os.path.isfile(fileWithID):
            logging.warning(
                'The file: ' + fileWithID +
                ' already exists. The content will be used to get UUID.')
        else:
            result = getUniqueIDAndSaveToFile(filename=fileWithID)
            if not result:
                logging.error('Error while generating pilot logger id.')
        self.messageSender = messageSenderFactory(
            senderType=self.params['LoggingType'], params=self.params)
        if not self.messageSender:
            logging.error('Something went wrong - no messageSender created.')
Esempio n. 5
0
 def setUp(self):
     self.testFile = "UUID_to_store"
     getUniqueIDAndSaveToFile(self.testFile)
     self.badFile = "////"
     self.nonExistentFile = "abrakadabraToCzaryIMagia"
Esempio n. 6
0
 def test_fail( self ):
   self.assertFalse( getUniqueIDAndSaveToFile( self.badFile ) )
Esempio n. 7
0
 def test_success( self ):
   self.assertTrue( getUniqueIDAndSaveToFile( self.testFile ) )
Esempio n. 8
0
 def setUp(self):
     self.testFile = 'UUID_to_store'
     getUniqueIDAndSaveToFile(self.testFile)
     self.badFile = '////'
     self.nonExistentFile = 'abrakadabraToCzaryIMagia'
Esempio n. 9
0
 def test_fail( self ):
   self.assertFalse( getUniqueIDAndSaveToFile( self.badFile ) )
Esempio n. 10
0
 def test_success( self ):
   self.assertTrue( getUniqueIDAndSaveToFile( self.testFile ) )