def POST(self): header('Content-Type', 'application/octet-stream') header('Access-Control-Allow-Origin', ctx.env.get('HTTP_ORIGIN')) header('Access-Control-Allow-Headers', ctx.env.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS')) header('Access-Control-Allow-Methods', '*') header('Access-Control-Allow-Credentials', 'true') try: payload = json.loads(data()) # generate entry timestamp payload['traceTimeentry'] = datetime.datetime.utcnow() payload['traceTimeentryUnix'] = calendar.timegm( payload['traceTimeentry'].timetuple( )) + payload['traceTimeentry'].microsecond / 1e6 # guess client IP payload['traceIp'] = ctx.env.get('HTTP_X_FORWARDED_FOR') if payload['traceIp'] is None: payload[ 'traceIp'] = ctx.ip # quand meme, cela peut etre None aussi # generate unique ID payload['traceId'] = str(uuid.uuid4()).replace('-', '').lower() trace(payload=payload) except ValueError: raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter list') except Exception, e: print traceback.format_exc() raise InternalError(e)
def post(self): """ Trace endpoint used by the pilot and CLI clients to post data access information. .. :quickref: Trace; Send trace. :<json dict payload: Dictionary contain the trace information. :status 201: Created. :status 400: Cannot decode json data. """ headers = self.get_headers() payload = json_parameters() # generate entry timestamp payload['traceTimeentry'] = datetime.datetime.utcnow() payload['traceTimeentryUnix'] = calendar.timegm( payload['traceTimeentry'].timetuple( )) + payload['traceTimeentry'].microsecond / 1e6 # guess client IP payload['traceIp'] = request.headers.get('X-Forwarded-For', default=request.remote_addr) # generate unique ID payload['traceId'] = str(uuid.uuid4()).replace('-', '').lower() trace(payload=payload) return 'Created', 201, headers
def post(self): """ Trace endpoint used by the pilot and CLI clients to post data access information. .. :quickref: Trace; Send trace. :<json dict payload: Dictionary contain the trace information. :status 201: Created. :status 400: Cannot decode json data. :status 500: Internal Error. """ try: payload = json.loads(request.data) # generate entry timestamp payload['traceTimeentry'] = datetime.datetime.utcnow() payload['traceTimeentryUnix'] = calendar.timegm(payload['traceTimeentry'].timetuple()) + payload['traceTimeentry'].microsecond / 1e6 # guess client IP payload['ip'] = request.environ.get('HTTP_X_FORWARDED_FOR') if payload['ip'] is None: payload['ip'] = request.remote_addr # generate unique ID payload['traceId'] = str(uuid.uuid4()).replace('-', '').lower() trace(payload=payload) except ValueError: return generate_http_error_flask(400, 'ValueError', 'Cannot decode json parameter list') except Exception, e: print traceback.format_exc() return e, 500
def post(self): """ Trace endpoint used by the pilot and CLI clients to post data access information. .. :quickref: Trace; Send trace. :<json dict payload: Dictionary contain the trace information. :status 201: Created. :status 400: Cannot decode json data. :status 500: Internal Error. """ headers = Headers() headers.set('Content-Type', 'application/octet-stream') headers.set('Access-Control-Allow-Origin', request.environ.get('HTTP_ORIGIN')) headers.set('Access-Control-Allow-Headers', request.environ.get('HTTP_ACCESS_CONTROL_REQUEST_HEADERS')) headers.set('Access-Control-Allow-Methods', '*') headers.set('Access-Control-Allow-Credentials', 'true') try: payload = json.loads(request.data) # generate entry timestamp payload['traceTimeentry'] = datetime.datetime.utcnow() payload['traceTimeentryUnix'] = calendar.timegm( payload['traceTimeentry'].timetuple( )) + payload['traceTimeentry'].microsecond / 1e6 # guess client IP payload['traceIp'] = request.headers.get( 'X-Forwarded-For', default=request.remote_addr) # generate unique ID payload['traceId'] = str(uuid.uuid4()).replace('-', '').lower() trace(payload=payload) except ValueError: return generate_http_error_flask( 400, 'ValueError', 'Cannot decode json parameter list', headers=headers) except Exception as error: print(traceback.format_exc()) return str(error), 500, headers return 'Created', 201, headers