Ejemplo n.º 1
0
def initializeDataLoggingHandler(serviceInfo):

    global dataPath
    global logDB
    logDB = DataLoggingDB()

    monitoringSection = PathFinder.getServiceSection(
        "DataManagement/DataLogging")
    #Get data location
    retDict = gConfig.getOption("%s/DataLocation" % monitoringSection,
                                "dataLoggingPlots")
    if not retDict['OK']:
        return retDict
    dataPath = retDict['Value'].strip()
    if "/" != dataPath[0]:
        dataPath = os.path.realpath(
            "%s/%s" %
            (gConfig.getValue('/LocalSite/InstancePath', rootPath), dataPath))
    gLogger.info("Data will be written into %s" % dataPath)
    try:
        os.makedirs(dataPath)
    except:
        pass
    try:
        testFile = "%s/mon.jarl.test" % dataPath
        fd = file(testFile, "w")
        fd.close()
        os.unlink(testFile)
    except IOError:
        gLogger.fatal("Can't write to %s" % dataPath)
        return S_ERROR("Data location is not writable")
    return S_OK()
Ejemplo n.º 2
0
def initializeDataLoggingHandler( serviceInfo ):
  """ handler initialisation """
  global gDataLoggingDB
  gDataLoggingDB = DataLoggingDB()

  res = gDataLoggingDB._connect()
  if not res['OK']:
    return res
  res = gDataLoggingDB._checkTable()
  if not res['OK'] and not res['Message'] == 'The requested table already exist':
    return res
  return S_OK()
Ejemplo n.º 3
0
    def setUp(self):
        """ set up

    :param self: self reference
    """
        self.log = gLogger.getSubLogger(self.__class__.__name__)

        if not self.__db:
            gConfig.setOptionValue("/DIRAC/Setup", "Test")
            gConfig.setOptionValue("/DIRAC/Setups/Test/DataManagement", "Test")
            spath = "/Systems/DataManagement/Test/Databases/DataLoggingDB"
            gConfig.setOptionValue("%s/%s" % (spath, "Host"), "127.0.0.1")
            gConfig.setOptionValue("%s/%s" % (spath, "DBName"), "AccountingDB")
            gConfig.setOptionValue("%s/%s" % (spath, "User"), "Dirac")
            gConfig.setOptionValue("%s/%s" % (spath, "Password"), "Dirac")
            self.__db = DataLoggingDB()