Esempio n. 1
0
	def exportStream(self, application, fromDate, toDate, file = None):

		session = models.getSession()
		
		q = session.query(models.Events).filter(models.Events.application_key==application, models.Events.created>=fromDate, models.Events.created<toDate)
		
		
		for row in q:
			if file == None:
				yield extras.toJSON(row.as_dict())+'\n'
			else:
				file.write(extras.toJSON(row.as_dict())+'\n')
Esempio n. 2
0
    def exportStream(self, application, fromDate, toDate, file=None):

        session = models.getSession()

        q = session.query(models.Events).filter(
            models.Events.application_key == application,
            models.Events.created >= fromDate,
            models.Events.created < toDate,
        )

        for row in q:
            if file == None:
                yield extras.toJSON(row.as_dict()) + "\n"
            else:
                file.write(extras.toJSON(row.as_dict()) + "\n")
Esempio n. 3
0
def buildResponse(content, secret, application=None):
    if isinstance(content, dict) == False:
        return content

    data = {}
    status = 200

    if 'status' in content:
        data = {'error': content['message']}
        status = content['status']
    else:
        data = content

    if application:
        data['liftpass-application'] = application

    data['liftpass-time'] = round(time.time())
    data = extras.toJSON(data)

    response = Response(data, status, {'content-type': 'application/json'})
    if secret:
        digest = hmac.new(secret, data.encode('utf-8'),
                          hashlib.sha256).hexdigest()
        response.headers['liftpass-hash'] = digest

    response.status_code = status

    return response
Esempio n. 4
0
def buildResponse(content, secret, application=None):
	if isinstance(content, dict) == False:
		return content

	data = {}
	status = 200
	
	if 'status' in content:
		data = {'error': content['message']}
		status = content['status']
	else:
		data = content
	
	if application:
		data['liftpass-application'] = application	

	data['liftpass-time'] = round(time.time())
	data = extras.toJSON(data)

	response = Response(data, status, {'content-type':'application/json'})
	if secret:
		digest = hmac.new(secret, data.encode('utf-8'), hashlib.sha256).hexdigest()
		response.headers['liftpass-hash'] = digest

	response.status_code = status

	return response
Esempio n. 5
0
	def exportFile(self, application, fromDate, toDate, file):
		session = models.getSession()
		q = session.query(models.Events).filter(models.Events.application_key==application, models.Events.created>=fromDate, models.Events.created<toDate)
		
		for row in q:	
			file.write(extras.toJSON(row.as_dict())+'\n')
			file.flush()
Esempio n. 6
0
    def exportFile(self, application, fromDate, toDate, file):
        session = models.getSession()
        q = session.query(models.Events).filter(
            models.Events.application_key == application,
            models.Events.created >= fromDate,
            models.Events.created < toDate,
        )

        for row in q:
            file.write(extras.toJSON(row.as_dict()) + "\n")
            file.flush()