Exemple #1
0
def getCorruptedFiles(request,dbview):
    par = Popularityparams()
    logger.info(dbview)
    dbviewValidation = {'detail':'v_CorruptedFilesDetail', 'siteSummary': 'v_corruptedFilesSiteSummary', 'dsSummary':'v_corruptedFilesDSSummary'}

    try:
        par.dbview = dbviewValidation[dbview]        
        logger.info(par.dbview)
    except Exception as ex:        
        raise ex
        return HttpResponseServerError(ex)
    
    try:
        par.setSiteName(request.GET.get('sitename', 'summary'))
        jdata = _getCorruptedFilesInTimeWindowJSON(par)
    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (pEx.param, pEx.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)


    #jdata = _getCorruptedFilesInTimeWindowJSON(par)
    return HttpResponse(jdata)
Exemple #2
0
def getDSStatInTimeWindow(request, MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))

        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        jdata = _getDSStatInTimeWindowJSON(par, MView)

    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)

    #jdata = _getDSStatInTimeWindowJSON(par,MView)
    return HttpResponse(jdata)
Exemple #3
0
def getDSStatInTimeWindow(request,MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days = 7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))

        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        jdata = _getDSStatInTimeWindowJSON(par,MView)

    except Paramvalidationexception as e:           
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex) 
    

    #jdata = _getDSStatInTimeWindowJSON(par,MView)
    return HttpResponse(jdata)
Exemple #4
0
def getProcessedDataSetStat(request):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))
        par.setAggregation(request.GET.get('aggr', 'day'))
        par.setProcessedDataSet(request.GET.get('name'))
        par.setN('1')
        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        """ 
        data indexing start from 0
        """
        data = _getSingleElementStat(par, 'DSName')
        
    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (pEx.param, pEx.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)

    return HttpResponse(data)
Exemple #5
0
def getTimeEvolutionPlotData(request,MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))
        par.setAggregation(request.GET.get('aggr', 'day'))
        par.setN(request.GET.get('n', '1'))


        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        if (par.FirstN == 0):
            return HttpResponseBadRequest("Given n not valid (param must be > 0)")


        """
        data indexing start from 0
        """
        idx = (par.FirstN)-1
        logger.info(MView)
        data = _getMostPopStatDict(par,MView)

    except Paramvalidationexception as e:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (pEx.param, pEx.cause))
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        #return HttpResponseBadRequest("Given %s not valid (%s)" % (e.param, e.cause))
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)

    jsonRes = {}
    listRes = []
    for i in data:
        series1 = []
        series2 = []
        for entry in data[i]['DATA']:
            millisecondSinceEpoch=1000*calendar.timegm(time.strptime(entry['TDAY'],'%Y/%m/%d'))
            if (par.orderVar == "totcpu"):
                series1.append( [  millisecondSinceEpoch, entry['TOTCPU'] ] )
            elif (par.orderVar == "naccess"):
                series1.append( [  millisecondSinceEpoch, entry['NACC'  ] ] )
            elif (par.orderVar == "nusers"):
                series1.append( [  millisecondSinceEpoch, entry['NUSERS'  ] ] )

        listRes.append({'name' : data[i]['COLLNAME'], 'data' : series1})
            #,
            #            {'label' : 'NACC', 'yaxis' : 1 , 'data' : series2}
            #             ]

    jsonRes = {'tstart': par.TStart, 'tstop': par.TStop, 'aggr': par.AggrFlag, 'data': listRes}
    jdata = json.dumps(jsonRes)

    return HttpResponse(jdata)
Exemple #6
0
def getPlotData(request,MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()
    try:
        par.setTStart(request.GET.get('tstart', start.strftime("%Y-%m-%d")))
        par.setTStop(request.GET.get('tstop', stop.strftime("%Y-%m-%d")))
        par.setAggregation(request.GET.get('aggr', 'day'))
        par.setN(request.GET.get('n', '1'))


        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))
        if (par.FirstN == 0):
            return HttpResponseBadRequest("Given n not valid (param must be > 0)")


        """
        data indexing start from 0
        """
        idx = (par.FirstN)-1
        
        data= _getMostPopStatDict(par,MView)        

    except Paramvalidationexception as e:
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)


    collData = data[idx]

    series1 = []
    series2 = []

    for entry in collData['DATA']:
        millisecondSinceEpoch=1000*calendar.timegm(time.strptime(entry['TDAY'],'%Y/%m/%d'))
        series1.append( [  millisecondSinceEpoch, entry['TOTCPU'] ] )
        series2.append( [  millisecondSinceEpoch, entry['NACC'  ] ] )  
    
    jsonRes = {'label' : collData['COLLNAME'], 'data' : series1}

    jdata = json.dumps(jsonRes)
    
    return HttpResponse(jdata)