def get(self): """ List the suspicious replicas on a list of RSEs. .. :quickref: SuspiciousReplicas; Get suspicious replicas. :resheader Content-Type: application/json :status 200: OK. :status 406: Not Acceptable. :returns: List of suspicious file replicas. """ rse_expression, younger_than, nattempts = None, None, None if request.query_string: query_string = request.query_string.decode(encoding='utf-8') try: params = loads(unquote(query_string)) except ValueError: params = parse_qs(query_string) if 'rse_expression' in params: rse_expression = params['rse_expression'][0] if 'younger_than' in params and params['younger_than'][0]: younger_than = datetime.strptime(params['younger_than'][0], "%Y-%m-%dT%H:%M:%S") if 'nattempts' in params: nattempts = int(params['nattempts'][0]) result = get_suspicious_files(rse_expression=rse_expression, younger_than=younger_than, nattempts=nattempts, vo=request.environ.get('vo')) return Response(render_json_list(result), 200, content_type='application/json')
def get(self): """ List the suspicious replicas on a list of RSEs. .. :quickref: SuspiciousReplicas; Get suspicious replicas. :resheader Content-Type: application/json :status 200: OK. :status 406: Not Acceptable. :status 500: Internal Error. :returns: List of suspicious file replicas. """ result = [] rse_expression = request.args.get('rse_expression', None) younger_than = request.args.get('younger_than', None) nattempts = request.args.get('nattempts', None) if younger_than: younger_than = datetime.strptime(younger_than, "%Y-%m-%dT%H:%M:%S.%f") try: result = get_suspicious_files(rse_expression=rse_expression, younger_than=younger_than, nattempts=nattempts) except RucioException as error: return generate_http_error_flask(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) return error, 500 return render_json_list(result)
def GET(self): """ List the suspicious replicas on a lsit of RSEs. HTTP Success: 200 OK HTTP Error: 406 Not Acceptable 500 InternalError """ header('Content-Type', 'application/json') result = [] rse_expression, younger_than, nattempts = None, None, None if ctx.query: try: params = loads(unquote(ctx.query[1:])) except ValueError: params = parse_qs(ctx.query[1:]) print(params) if 'rse_expression' in params: rse_expression = params['rse_expression'][0] if 'younger_than' in params and params['younger_than'][0]: younger_than = datetime.strptime(params['younger_than'][0], "%Y-%m-%dT%H:%M:%S") if 'nattempts' in params: nattempts = int(params['nattempts'][0]) try: result = get_suspicious_files(rse_expression=rse_expression, younger_than=younger_than, nattempts=nattempts, vo=ctx.env.get('vo')) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: print(format_exc()) raise InternalError(error) return render_json_list(result)