def initializeReportGeneratorHandler(serviceInfo): global gAccountingDB gAccountingDB = AccountingDB(readOnly=True) #Get data location reportSection = PathFinder.getServiceSection("Accounting/ReportGenerator") dataPath = gConfig.getValue("%s/DataLocation" % reportSection, "data/accountingGraphs") dataPath = dataPath.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/acc.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") gDataCache.setGraphsLocation(dataPath) gMonitor.registerActivity("plotsDrawn", "Drawn plot images", "Accounting reports", "plots", gMonitor.OP_SUM) gMonitor.registerActivity("reportsRequested", "Generated reports", "Accounting reports", "reports", gMonitor.OP_SUM) return S_OK()
def initializeReportGeneratorHandler( serviceInfo ): global gAccountingDB gAccountingDB = AccountingDB( readOnly = True ) #Get data location reportSection = PathFinder.getServiceSection( "Accounting/ReportGenerator" ) dataPath = gConfig.getValue( "%s/DataLocation" % reportSection, "data/accountingGraphs" ) dataPath = dataPath.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/acc.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" ) gDataCache.setGraphsLocation( dataPath ) gMonitor.registerActivity( "plotsDrawn", "Drawn plot images", "Accounting reports", "plots", gMonitor.OP_SUM ) gMonitor.registerActivity( "reportsRequested", "Generated reports", "Accounting reports", "reports", gMonitor.OP_SUM ) return S_OK()