Add task to process a DVLA response file:

* Currently we do nothing with the parsed response. We will
* update the status of the notifications in a separate PR
This commit is contained in:
Imdad Ahad
2017-05-04 10:31:18 +01:00
parent 4d0b90bbe2
commit f766f90207
4 changed files with 77 additions and 12 deletions

View File

@@ -4,20 +4,24 @@ from flask import current_app
FILE_LOCATION_STRUCTURE = 'service-{}-notify/{}.csv'
def get_s3_job_object(bucket_name, file_location):
def get_s3_object(bucket_name, file_location):
s3 = resource('s3')
return s3.Object(bucket_name, file_location)
s3_object = s3.Object(bucket_name, file_location)
return s3_object.get()['Body'].read()
def get_job_from_s3(service_id, job_id):
bucket_name = current_app.config['CSV_UPLOAD_BUCKET_NAME']
file_location = FILE_LOCATION_STRUCTURE.format(service_id, job_id)
obj = get_s3_job_object(bucket_name, file_location)
return obj.get()['Body'].read().decode('utf-8')
job = _job_from_s3(service_id, job_id)
return job
def remove_job_from_s3(service_id, job_id):
job = _job_from_s3(service_id, job_id)
return job.delete()
def _job_from_s3():
bucket_name = current_app.config['CSV_UPLOAD_BUCKET_NAME']
file_location = FILE_LOCATION_STRUCTURE.format(service_id, job_id)
obj = get_s3_job_object(bucket_name, file_location)
return obj.delete()
obj = get_s3_object(bucket_name, file_location).decode('utf-8')
return obj