Ejemplo n.º 1
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.setIsCentralUser(request.GET.get('centraluser', '0'))
        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))

        #par.table = 'DS'
        """ 
        data indexing start from 0
        """
        data = dataH.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)
Ejemplo n.º 2
0
def getTimeEvolutionPlotData(request,MView=''):

    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()

    par.table = MView
    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.setIsCentralUser(request.GET.get('centraluser', '0'))
        
        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)")


        jdata = dataH.getTimeEvolutionPlotDataJSON(par)
        return HttpResponse(jdata)
    
    except Paramvalidationexception as e:
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)
Ejemplo n.º 3
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.setIsCentralUser(request.GET.get('centraluser', '0'))
        par.setOrder(request.GET.get('orderby', 'totcpu'))
        par.setSiteName(request.GET.get('sitename', 'summary'))

        #par.table = 'DS'
        """ 
        data indexing start from 0
        """
        data = dataH.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)
Ejemplo n.º 4
0
def getTimeEvolutionPlotData(request, MView=''):

    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()

    par.table = MView
    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.setIsCentralUser(request.GET.get('centraluser', '0'))

        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)")

        jdata = dataH.getTimeEvolutionPlotDataJSON(par)
        return HttpResponse(jdata)

    except Paramvalidationexception as e:
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)
Ejemplo n.º 5
0
def getDSStatInTimeWindow(request,MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days = 7)
    par = Popularityparams()

    par.table = MView
    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.setIsCentralUser(request.GET.get('centraluser', '0'))
        jdata = dataH.getDSStatInTimeWindowJSON(par)
        
    except Paramvalidationexception as e:
        return HttpResponseBadRequest(e.getmessage())
    except popDB.PopularityDBException as dbe:
        return HttpResponseServerError(dbe.getmessage())
    except Exception as ex:
        return HttpResponseServerError(ex)
        
    return HttpResponse(jdata)
Ejemplo n.º 6
0
def getDSStatInTimeWindow(request, MView=''):
    stop = datetime.now()
    start = datetime.now() - timedelta(days=7)
    par = Popularityparams()

    par.table = MView
    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.setIsCentralUser(request.GET.get('centraluser', '0'))
        jdata = dataH.getDSStatInTimeWindowJSON(par)

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

    return HttpResponse(jdata)